Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Smithy typescript codegen generates un-buildable code for awsJson services when using streaming #1051

Open
AnirudhKonduru opened this issue Oct 20, 2023 · 1 comment

Comments

@AnirudhKonduru
Copy link

Produces the following output when npm run build is run:

> concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'
...
$ tsc -p tsconfig.types.json
[build:cjs] src/protocols/Aws_json1_0.ts(52,36): error TS2552: Cannot find name 'de_string'. Did you mean 'String'?
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[build:cjs] yarn run build:cjs exited with code 2
[build:types] src/protocols/Aws_json1_0.ts(52,36): error TS2552: Cannot find name 'de_string'. Did you mean 'String'?
[build:es] src/protocols/Aws_json1_0.ts(52,36): error TS2552: Cannot find name 'de_string'. Did you mean 'String'?
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[build:types] yarn run build:types exited with code 1
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[build:es] yarn run build:es exited with code 2

To reproduce, build this minimal main.smithy file:

$version: "2"

namespace smithy.example
use aws.protocols#awsJson1_0

@awsJson1_0
service ExampleService {
    version: "2022-01-01"
    operations: [Echo]
}

structure MessageItem {
    content: String
}
@streaming
union MessageStream {
    content: MessageItem
}

@output
structure EchoResponse {
    @httpHeader("x-custom-header")
    customHeader: String
    @httpPayload
    stream: MessageStream
}

@http(code: 200, method: "POST", uri: "/echo")
operation Echo {
    input := {
        message: String
    } 
    output: EchoResponse
}

With the following dependencies:

"software.amazon.smithy.typescript:smithy-typescript-codegen:0.18.0",
"software.amazon.smithy.typescript:smithy-aws-typescript-codegen:0.18.0",
"software.amazon.smithy:smithy-aws-traits:1.39.0"

Tested with smithy-cli versions 1.33, 1.34, 1.40.

@AnirudhKonduru
Copy link
Author

I should add that this seems to be broken if we're using @awsJson1, but not with @restJson.
It also happens only if the output structure has both, a field marked with @httpPayload who's type is @streaming and a field marked with @httpHeader along side it. Removing any of these will let it generate buildable code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant