diff --git a/codegen/gradle.properties b/codegen/gradle.properties index caeb2216e6e4..a1d15eb6ff76 100644 --- a/codegen/gradle.properties +++ b/codegen/gradle.properties @@ -1,4 +1,4 @@ -smithyVersion=1.61.0 +smithyVersion=1.62.0 smithyGradleVersion=1.2.0 smithyPluginVersion=0.6.0 org.gradle.jvmargs=-Xmx4096M \ No newline at end of file diff --git a/private/aws-protocoltests-json-10-schema/test/functional/awsjson1_0.spec.ts b/private/aws-protocoltests-json-10-schema/test/functional/awsjson1_0.spec.ts index c92d068a5c61..4ac709f75895 100644 --- a/private/aws-protocoltests-json-10-schema/test/functional/awsjson1_0.spec.ts +++ b/private/aws-protocoltests-json-10-schema/test/functional/awsjson1_0.spec.ts @@ -802,6 +802,50 @@ it("AwsJson10FooErrorWithDunderTypeUriAndNamespace:Error:GreetingWithErrors", as fail("Expected an exception to be thrown from response"); }); +/** + * Some services serialize errors using __type, and if the response includes additional shapes that belong to a different namespace there'll be a nested __type property that must not be considered when determining which error to be surfaced. + * + * For an example service see Amazon DynamoDB. + */ +it("AwsJson10FooErrorWithNestedTypeProperty:Error:GreetingWithErrors", async () => { + const client = new JSONRPC10Client({ + ...clientParams, + requestHandler: new ResponseDeserializationTestHandler( + false, + 500, + { + "content-type": "application/x-amz-json-1.0", + }, + `{ + "__type": "aws.protocoltests.json10#FooError", + "ErrorDetails": [ + { + "__type": "com.amazon.internal#ErrorDetails", + "reason": "Some reason" + } + ] + }` + ), + }); + + const params: any = {}; + const command = new GreetingWithErrorsCommand(params); + + try { + await client.send(command); + } catch (err) { + if (err.name !== "FooError") { + console.log(err); + fail(`Expected a FooError to be thrown, got ${err.name} instead`); + return; + } + const r: any = err; + expect(r["$metadata"].httpStatusCode).toBe(500); + return; + } + fail("Expected an exception to be thrown from response"); +}); + /** * Custom endpoints supplied by users can have paths */ diff --git a/private/aws-protocoltests-json-10/test/functional/awsjson1_0.spec.ts b/private/aws-protocoltests-json-10/test/functional/awsjson1_0.spec.ts index c92d068a5c61..4ac709f75895 100644 --- a/private/aws-protocoltests-json-10/test/functional/awsjson1_0.spec.ts +++ b/private/aws-protocoltests-json-10/test/functional/awsjson1_0.spec.ts @@ -802,6 +802,50 @@ it("AwsJson10FooErrorWithDunderTypeUriAndNamespace:Error:GreetingWithErrors", as fail("Expected an exception to be thrown from response"); }); +/** + * Some services serialize errors using __type, and if the response includes additional shapes that belong to a different namespace there'll be a nested __type property that must not be considered when determining which error to be surfaced. + * + * For an example service see Amazon DynamoDB. + */ +it("AwsJson10FooErrorWithNestedTypeProperty:Error:GreetingWithErrors", async () => { + const client = new JSONRPC10Client({ + ...clientParams, + requestHandler: new ResponseDeserializationTestHandler( + false, + 500, + { + "content-type": "application/x-amz-json-1.0", + }, + `{ + "__type": "aws.protocoltests.json10#FooError", + "ErrorDetails": [ + { + "__type": "com.amazon.internal#ErrorDetails", + "reason": "Some reason" + } + ] + }` + ), + }); + + const params: any = {}; + const command = new GreetingWithErrorsCommand(params); + + try { + await client.send(command); + } catch (err) { + if (err.name !== "FooError") { + console.log(err); + fail(`Expected a FooError to be thrown, got ${err.name} instead`); + return; + } + const r: any = err; + expect(r["$metadata"].httpStatusCode).toBe(500); + return; + } + fail("Expected an exception to be thrown from response"); +}); + /** * Custom endpoints supplied by users can have paths */ diff --git a/private/aws-protocoltests-json-schema/test/functional/awsjson1_1.spec.ts b/private/aws-protocoltests-json-schema/test/functional/awsjson1_1.spec.ts index 0c730031b8cf..84f0ff6f99e4 100644 --- a/private/aws-protocoltests-json-schema/test/functional/awsjson1_1.spec.ts +++ b/private/aws-protocoltests-json-schema/test/functional/awsjson1_1.spec.ts @@ -1070,6 +1070,50 @@ it("AwsJson11FooErrorWithDunderTypeUriAndNamespace:Error:GreetingWithErrors", as fail("Expected an exception to be thrown from response"); }); +/** + * Some services serialize errors using __type, and if the response includes additional shapes that belong to a different namespace there'll be a nested __type property that must not be considered when determining which error to be surfaced. + * + * For an example service see Amazon DynamoDB. + */ +it("AwsJson11FooErrorWithNestedTypeProperty:Error:GreetingWithErrors", async () => { + const client = new JsonProtocolClient({ + ...clientParams, + requestHandler: new ResponseDeserializationTestHandler( + false, + 500, + { + "content-type": "application/x-amz-json-1.1", + }, + `{ + "__type": "aws.protocoltests.restjson#FooError", + "ErrorDetails": [ + { + "__type": "com.amazon.internal#ErrorDetails", + "reason": "Some reason" + } + ] + }` + ), + }); + + const params: any = {}; + const command = new GreetingWithErrorsCommand(params); + + try { + await client.send(command); + } catch (err) { + if (err.name !== "FooError") { + console.log(err); + fail(`Expected a FooError to be thrown, got ${err.name} instead`); + return; + } + const r: any = err; + expect(r["$metadata"].httpStatusCode).toBe(500); + return; + } + fail("Expected an exception to be thrown from response"); +}); + /** * Custom endpoints supplied by users can have paths */ diff --git a/private/aws-protocoltests-json/test/functional/awsjson1_1.spec.ts b/private/aws-protocoltests-json/test/functional/awsjson1_1.spec.ts index 0c730031b8cf..84f0ff6f99e4 100644 --- a/private/aws-protocoltests-json/test/functional/awsjson1_1.spec.ts +++ b/private/aws-protocoltests-json/test/functional/awsjson1_1.spec.ts @@ -1070,6 +1070,50 @@ it("AwsJson11FooErrorWithDunderTypeUriAndNamespace:Error:GreetingWithErrors", as fail("Expected an exception to be thrown from response"); }); +/** + * Some services serialize errors using __type, and if the response includes additional shapes that belong to a different namespace there'll be a nested __type property that must not be considered when determining which error to be surfaced. + * + * For an example service see Amazon DynamoDB. + */ +it("AwsJson11FooErrorWithNestedTypeProperty:Error:GreetingWithErrors", async () => { + const client = new JsonProtocolClient({ + ...clientParams, + requestHandler: new ResponseDeserializationTestHandler( + false, + 500, + { + "content-type": "application/x-amz-json-1.1", + }, + `{ + "__type": "aws.protocoltests.restjson#FooError", + "ErrorDetails": [ + { + "__type": "com.amazon.internal#ErrorDetails", + "reason": "Some reason" + } + ] + }` + ), + }); + + const params: any = {}; + const command = new GreetingWithErrorsCommand(params); + + try { + await client.send(command); + } catch (err) { + if (err.name !== "FooError") { + console.log(err); + fail(`Expected a FooError to be thrown, got ${err.name} instead`); + return; + } + const r: any = err; + expect(r["$metadata"].httpStatusCode).toBe(500); + return; + } + fail("Expected an exception to be thrown from response"); +}); + /** * Custom endpoints supplied by users can have paths */ diff --git a/private/aws-protocoltests-restjson-schema/test/functional/restjson1.spec.ts b/private/aws-protocoltests-restjson-schema/test/functional/restjson1.spec.ts index 8e37cb7ea150..a0735a61c034 100644 --- a/private/aws-protocoltests-restjson-schema/test/functional/restjson1.spec.ts +++ b/private/aws-protocoltests-restjson-schema/test/functional/restjson1.spec.ts @@ -2240,6 +2240,50 @@ it("RestJsonFooErrorWithDunderTypeUriAndNamespace:Error:GreetingWithErrors", asy fail("Expected an exception to be thrown from response"); }); +/** + * Some services serialize errors using __type, and if the response includes additional shapes that belong to a different namespace there'll be a nested __type property that must not be considered when determining which error to be surfaced. + * + * For an example service see Amazon DynamoDB. + */ +it("RestJsonFooErrorWithNestedTypeProperty:Error:GreetingWithErrors", async () => { + const client = new RestJsonProtocolClient({ + ...clientParams, + requestHandler: new ResponseDeserializationTestHandler( + false, + 500, + { + "content-type": "application/json", + }, + `{ + "__type": "aws.protocoltests.restjson#FooError", + "ErrorDetails": [ + { + "__type": "com.amazon.internal#ErrorDetails", + "reason": "Some reason" + } + ] + }` + ), + }); + + const params: any = {}; + const command = new GreetingWithErrorsCommand(params); + + try { + await client.send(command); + } catch (err) { + if (err.name !== "FooError") { + console.log(err); + fail(`Expected a FooError to be thrown, got ${err.name} instead`); + return; + } + const r: any = err; + expect(r["$metadata"].httpStatusCode).toBe(500); + return; + } + fail("Expected an exception to be thrown from response"); +}); + /** * Custom endpoints supplied by users can have paths */ @@ -3577,7 +3621,7 @@ it("RestJsonIgnoreQueryParamsInResponse:Response", async () => { { "content-type": "application/json", }, - `{}` + `{"baz":"bam"}` ), }); @@ -3592,30 +3636,18 @@ it("RestJsonIgnoreQueryParamsInResponse:Response", async () => { return; } expect(r["$metadata"].httpStatusCode).toBe(200); -}); - -/** - * This test is similar to RestJsonIgnoreQueryParamsInResponse, - * but it ensures that clients gracefully handle responses from - * the server that do not serialize an empty JSON object. - */ -it("RestJsonIgnoreQueryParamsInResponseNoPayload:Response", async () => { - const client = new RestJsonProtocolClient({ - ...clientParams, - requestHandler: new ResponseDeserializationTestHandler(true, 200, undefined, ``), + const paramsToValidate: any = [ + { + baz: "bam", + }, + ][0]; + Object.keys(paramsToValidate).forEach((param) => { + expect( + r[param], + `The output field ${param} should have been defined in ${JSON.stringify(r, null, 2)}` + ).toBeDefined(); + expect(equivalentContents(paramsToValidate[param], r[param])).toBe(true); }); - - const params: any = {}; - const command = new IgnoreQueryParamsInResponseCommand(params); - - let r: any; - try { - r = await client.send(command); - } catch (err) { - fail("Expected a valid response to be returned, got " + err); - return; - } - expect(r["$metadata"].httpStatusCode).toBe(200); }); /** diff --git a/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts b/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts index 8e37cb7ea150..a0735a61c034 100644 --- a/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts +++ b/private/aws-protocoltests-restjson/test/functional/restjson1.spec.ts @@ -2240,6 +2240,50 @@ it("RestJsonFooErrorWithDunderTypeUriAndNamespace:Error:GreetingWithErrors", asy fail("Expected an exception to be thrown from response"); }); +/** + * Some services serialize errors using __type, and if the response includes additional shapes that belong to a different namespace there'll be a nested __type property that must not be considered when determining which error to be surfaced. + * + * For an example service see Amazon DynamoDB. + */ +it("RestJsonFooErrorWithNestedTypeProperty:Error:GreetingWithErrors", async () => { + const client = new RestJsonProtocolClient({ + ...clientParams, + requestHandler: new ResponseDeserializationTestHandler( + false, + 500, + { + "content-type": "application/json", + }, + `{ + "__type": "aws.protocoltests.restjson#FooError", + "ErrorDetails": [ + { + "__type": "com.amazon.internal#ErrorDetails", + "reason": "Some reason" + } + ] + }` + ), + }); + + const params: any = {}; + const command = new GreetingWithErrorsCommand(params); + + try { + await client.send(command); + } catch (err) { + if (err.name !== "FooError") { + console.log(err); + fail(`Expected a FooError to be thrown, got ${err.name} instead`); + return; + } + const r: any = err; + expect(r["$metadata"].httpStatusCode).toBe(500); + return; + } + fail("Expected an exception to be thrown from response"); +}); + /** * Custom endpoints supplied by users can have paths */ @@ -3577,7 +3621,7 @@ it("RestJsonIgnoreQueryParamsInResponse:Response", async () => { { "content-type": "application/json", }, - `{}` + `{"baz":"bam"}` ), }); @@ -3592,30 +3636,18 @@ it("RestJsonIgnoreQueryParamsInResponse:Response", async () => { return; } expect(r["$metadata"].httpStatusCode).toBe(200); -}); - -/** - * This test is similar to RestJsonIgnoreQueryParamsInResponse, - * but it ensures that clients gracefully handle responses from - * the server that do not serialize an empty JSON object. - */ -it("RestJsonIgnoreQueryParamsInResponseNoPayload:Response", async () => { - const client = new RestJsonProtocolClient({ - ...clientParams, - requestHandler: new ResponseDeserializationTestHandler(true, 200, undefined, ``), + const paramsToValidate: any = [ + { + baz: "bam", + }, + ][0]; + Object.keys(paramsToValidate).forEach((param) => { + expect( + r[param], + `The output field ${param} should have been defined in ${JSON.stringify(r, null, 2)}` + ).toBeDefined(); + expect(equivalentContents(paramsToValidate[param], r[param])).toBe(true); }); - - const params: any = {}; - const command = new IgnoreQueryParamsInResponseCommand(params); - - let r: any; - try { - r = await client.send(command); - } catch (err) { - fail("Expected a valid response to be returned, got " + err); - return; - } - expect(r["$metadata"].httpStatusCode).toBe(200); }); /** diff --git a/private/aws-restjson-server/test/functional/restjson1.spec.ts b/private/aws-restjson-server/test/functional/restjson1.spec.ts index 1f5660667c1b..7e933e4098c7 100644 --- a/private/aws-restjson-server/test/functional/restjson1.spec.ts +++ b/private/aws-restjson-server/test/functional/restjson1.spec.ts @@ -4340,7 +4340,9 @@ it("RestJsonStringPayloadUnsatisfiableAccept:MalformedRequest", async () => { it("RestJsonIgnoreQueryParamsInResponse:ServerResponse", async () => { class TestService implements Partial> { IgnoreQueryParamsInResponse(input: any, ctx: {}): Promise { - const response = {} as any; + const response = { + baz: "bam", + } as any; return Promise.resolve({ ...response, $metadata: {} }); } } @@ -4382,7 +4384,7 @@ it("RestJsonIgnoreQueryParamsInResponse:ServerResponse", async () => { expect(r.body, `Body was undefined.`).toBeDefined(); const utf8Encoder = __utf8Encoder; - const bodyString = `{}`; + const bodyString = `{\"baz\":\"bam\"}`; const unequalParts: any = compareEquivalentJsonBodies(bodyString, r.body.toString()); expect(unequalParts).toBeUndefined(); }); diff --git a/scripts/generate-clients/config.js b/scripts/generate-clients/config.js index 239b61d46a15..8d3531f4ab9d 100644 --- a/scripts/generate-clients/config.js +++ b/scripts/generate-clients/config.js @@ -1,7 +1,7 @@ // Update this commit when taking up new changes from smithy-typescript. module.exports = { // Use full commit hash as we explicitly fetch it. - SMITHY_TS_COMMIT: "58c7732ccb3d37a38d238019f38c7e1c136eeedf", + SMITHY_TS_COMMIT: "7be586d88edd5c9933d7323210110c79543f1a8c", }; if (module.exports.SMITHY_TS_COMMIT.length < 40) {