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

Generated clients send incorrect "Accept: */*" header #570

Closed
jamesls opened this issue Jul 9, 2022 · 3 comments
Closed

Generated clients send incorrect "Accept: */*" header #570

jamesls opened this issue Jul 9, 2022 · 3 comments

Comments

@jamesls
Copy link

jamesls commented Jul 9, 2022

For context, my use case is to try and get a smithy-typescript client (in the browser) to talk to a smithy-rs service that are both generated from the same smithy model. I'm almost there, except that I'm running into an issue where the smithy-rs service is rejecting requests from the generated client because it sends an Accept: */* in its request. See smithy-lang/smithy-rs#1544.

Digging into it more, the service side validation comes from this PR here, which cites the smithy protocol tests, and if I'm reading the tests correctly, it seems like it's doing the right thing by requiring Accept: application/json for rest-json or allowing it to be omitted (I think).

The headers sent from the generated client are:

Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.5
amz-sdk-invocation-id: 2d5e2fc9-f69e-4ffe-bede-d463d995d2ea
amz-sdk-request: attempt=1; max=3
Connection: keep-alive
content-type: application/json
Host: (... redacted ...)
Origin: (... redacted ...)
Referer: (... redacted ...)
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Firefox/91.0
x-amz-user-agent: aws-sdk-js/0.1.0 os/macOS/10.15 lang/js md/browser/Firefox_91.0 api/(redacted)/0.1.0

Regardless of what end the fix is on, it seems like the smithy-typescript clients should be able to talk to the smithy-rs services.

@adamthom-amzn
Copy link
Contributor

adamthom-amzn commented Jul 11, 2022

There is no reason for a Smithy service to have more strict handling of Accept than the HTTP RFCs describe. */* is a perfectly valid value for this.

edited to add: that being said, the client has knowledge of what the output structure looks like, so if it's a structure and the protocol is restJson1, application/json is a better value for the header.

@jamesls
Copy link
Author

jamesls commented Jul 12, 2022

I suppose there's nothing explicitly called out in those protocol tests for Accept: */* (it's only explicit that you can't send unsupported media types) but it's also not clear what the expected behavior should be if the clients send Accept: */* and gets back something besides application/json or any of the other supported content types in the restJson1 protocol.

@gosar
Copy link
Contributor

gosar commented Jan 25, 2023

Seems like this is addressed by smithy-lang/smithy#1365 and smithy-lang/smithy-rs#1544. Resolving.

@gosar gosar closed this as completed Jan 25, 2023
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

3 participants