Skip to content

Conversation

trivikr
Copy link
Member

@trivikr trivikr commented Jan 31, 2020

Issue #, if available:
Refs: smithy-lang/smithy-typescript#112

Description of changes:
codegen to remove __type from Exception

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@trivikr
Copy link
Member Author

trivikr commented Jan 31, 2020

CI failure:

$ tsc
lerna ERR! yarn run pretest exited 2 in '@aws-sdk/client-apigatewaymanagementapi'
lerna ERR! yarn run pretest stdout:
$ tsc
protocols/Aws_restJson1_1.ts(326,9): error TS2741: Property '__type' is missing in type '{ name: "ForbiddenException"; $fault: "client"; $metadata: __ResponseMetadata; }' but required in type 'ForbiddenException'.
protocols/Aws_restJson1_1.ts(338,9): error TS2741: Property '__type' is missing in type '{ name: "GoneException"; $fault: "client"; $metadata: __ResponseMetadata; }' but required in type 'GoneException'.
protocols/Aws_restJson1_1.ts(350,9): error TS2741: Property '__type' is missing in type '{ name: "LimitExceededException"; $fault: "client"; $metadata: __ResponseMetadata; }' but required in type 'LimitExceededException'.
protocols/Aws_restJson1_1.ts(362,9): error TS2741: Property '__type' is missing in type '{ name: "PayloadTooLargeException"; $fault: "client"; $metadata: __ResponseMetadata; Message: undefined; }' but required in type 'PayloadTooLargeException'.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@trivikr
Copy link
Member Author

trivikr commented Feb 3, 2020

This fails as __type is required in SmithyException interface

/**
* The shape ID name of the exception.
*/
readonly __type: string;

@trivikr
Copy link
Member Author

trivikr commented Feb 3, 2020

__type is also parsed while deserialization

const errorTypeParts: String = parsedOutput.body["__type"].split("#");
errorCode =
errorTypeParts[1] === undefined ? errorTypeParts[0] : errorTypeParts[1];

CodeGen:

@Override
protected void writeErrorCodeParser(GenerationContext context) {
TypeScriptWriter writer = context.getWriter();
// parsedOutput is in scope because HttpRpcProtocolGenerator.isErrorCodeInBody is true
writer.write("const errorTypeParts: String = parsedOutput.body[\"__type\"].split('#');");
writer.write("errorCode = (errorTypeParts[1] === undefined) ? errorTypeParts[0] : errorTypeParts[1];");
}

@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (smithy-codegen@2b64381). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@                Coverage Diff                @@
##             smithy-codegen     #827   +/-   ##
=================================================
  Coverage                  ?   92.38%           
=================================================
  Files                     ?      147           
  Lines                     ?     2915           
  Branches                  ?      509           
=================================================
  Hits                      ?     2693           
  Misses                    ?      222           
  Partials                  ?        0

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2b64381...62f94f5. Read the comment docs.

@trivikr trivikr merged commit a15c9c3 into aws:smithy-codegen Feb 3, 2020
@trivikr trivikr deleted the clients-update branch February 3, 2020 18:27
@lock
Copy link

lock bot commented Feb 10, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants