From e09ab337936afa5e20f47b8dc776a0f360f3e2b3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Jun 2025 03:28:06 +0000 Subject: [PATCH 1/4] Initial plan From d3e09fb658c29255fd33f05d69eb15da588dc201 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Jun 2025 03:32:08 +0000 Subject: [PATCH 2/4] Add failing test for null jsonBody serialization Co-authored-by: swapnil-nagar <1988068+swapnil-nagar@users.noreply.github.com> --- test/converters/toRpcHttp.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/converters/toRpcHttp.test.ts b/test/converters/toRpcHttp.test.ts index bbc056f..e810bb0 100644 --- a/test/converters/toRpcHttp.test.ts +++ b/test/converters/toRpcHttp.test.ts @@ -54,6 +54,11 @@ describe('toRpcHttp', () => { ); }); + it('response class json null', async () => { + const result = await toRpcHttp('invocId', new HttpResponse({ jsonBody: null })); + expect(result).to.deep.equal(getExpectedRpcHttp('null', jsonHeaders)); + }); + it('undefined', async () => { const result = await toRpcHttp('invocId', {}); expect(result).to.deep.equal(getExpectedRpcHttp('', {})); From 201789254c9583c213b2585fb8dec4f0ba8dae7d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Jun 2025 03:34:14 +0000 Subject: [PATCH 3/4] Fix null jsonBody serialization in HttpResponse Co-authored-by: swapnil-nagar <1988068+swapnil-nagar@users.noreply.github.com> --- src/http/HttpResponse.ts | 3 +-- types/InvocationContext.d.ts | 4 ++-- types/input.d.ts | 2 +- types/output.d.ts | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/http/HttpResponse.ts b/src/http/HttpResponse.ts index a71d43c..53b4027 100644 --- a/src/http/HttpResponse.ts +++ b/src/http/HttpResponse.ts @@ -6,7 +6,6 @@ import { HttpResponseInit } from '@azure/functions'; import { Blob } from 'buffer'; import { ReadableStream } from 'stream/web'; import { FormData, Headers, Response as uResponse, ResponseInit as uResponseInit } from 'undici'; -import { isDefined } from '../utils/nonNull'; interface InternalHttpResponseInit extends HttpResponseInit { undiciResponse?: uResponse; @@ -27,7 +26,7 @@ export class HttpResponse implements types.HttpResponse { this.#uRes = init.undiciResponse; } else { const uResInit: uResponseInit = { status: init.status, headers: init.headers }; - if (isDefined(init.jsonBody)) { + if (init.jsonBody !== undefined) { this.#uRes = uResponse.json(init.jsonBody, uResInit); } else { this.#uRes = new uResponse(init.body, uResInit); diff --git a/types/InvocationContext.d.ts b/types/InvocationContext.d.ts index 8815bdf..c991557 100644 --- a/types/InvocationContext.d.ts +++ b/types/InvocationContext.d.ts @@ -129,7 +129,7 @@ export interface InvocationContextExtraInputs { * @input the configuration object for this SQL input */ get(input: SqlInput): unknown; - + /** * Get a secondary MySql items input for this invocation * @input the configuration object for this MySql input @@ -223,7 +223,7 @@ export interface InvocationContextExtraOutputs { * @message the output event(s) value */ set(output: EventGridOutput, events: EventGridPartialEvent | EventGridPartialEvent[]): void; - + /** * Set a secondary MySql items output for this invocation * @output the configuration object for this MySql output diff --git a/types/input.d.ts b/types/input.d.ts index 52d8c68..b264405 100644 --- a/types/input.d.ts +++ b/types/input.d.ts @@ -4,10 +4,10 @@ import { CosmosDBInput, CosmosDBInputOptions } from './cosmosDB'; import { GenericInputOptions } from './generic'; import { FunctionInput } from './index'; +import { MySqlInput, MySqlInputOptions } from './mySql'; import { SqlInput, SqlInputOptions } from './sql'; import { StorageBlobInput, StorageBlobInputOptions } from './storage'; import { TableInput, TableInputOptions } from './table'; -import { MySqlInput, MySqlInputOptions } from './mySql'; import { WebPubSubConnectionInput, WebPubSubConnectionInputOptions, diff --git a/types/output.d.ts b/types/output.d.ts index b9d9d83..e9e08d9 100644 --- a/types/output.d.ts +++ b/types/output.d.ts @@ -7,6 +7,7 @@ import { EventHubOutput, EventHubOutputOptions } from './eventHub'; import { GenericOutputOptions } from './generic'; import { HttpOutput, HttpOutputOptions } from './http'; import { FunctionOutput } from './index'; +import { MySqlOutput, MySqlOutputOptions } from './mySql'; import { ServiceBusQueueOutput, ServiceBusQueueOutputOptions, @@ -16,7 +17,6 @@ import { import { SqlOutput, SqlOutputOptions } from './sql'; import { StorageBlobOutput, StorageBlobOutputOptions, StorageQueueOutput, StorageQueueOutputOptions } from './storage'; import { TableOutput, TableOutputOptions } from './table'; -import { MySqlOutput, MySqlOutputOptions } from './mySql'; import { WebPubSubOutput, WebPubSubOutputOptions } from './webpubsub'; /** From 15e863702995fc4b83982cdbfb834f5355db4f21 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Jun 2025 03:37:18 +0000 Subject: [PATCH 4/4] Add comprehensive tests for JSON primitive types Co-authored-by: swapnil-nagar <1988068+swapnil-nagar@users.noreply.github.com> --- test/converters/toRpcHttp.test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/converters/toRpcHttp.test.ts b/test/converters/toRpcHttp.test.ts index e810bb0..7d928ba 100644 --- a/test/converters/toRpcHttp.test.ts +++ b/test/converters/toRpcHttp.test.ts @@ -59,6 +59,16 @@ describe('toRpcHttp', () => { expect(result).to.deep.equal(getExpectedRpcHttp('null', jsonHeaders)); }); + it('response class json boolean false', async () => { + const result = await toRpcHttp('invocId', new HttpResponse({ jsonBody: false })); + expect(result).to.deep.equal(getExpectedRpcHttp('false', jsonHeaders)); + }); + + it('response class json number zero', async () => { + const result = await toRpcHttp('invocId', new HttpResponse({ jsonBody: 0 })); + expect(result).to.deep.equal(getExpectedRpcHttp('0', jsonHeaders)); + }); + it('undefined', async () => { const result = await toRpcHttp('invocId', {}); expect(result).to.deep.equal(getExpectedRpcHttp('', {}));