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

Add restJson1 protocol test for content-type and operation with no input #2322

Merged
merged 1 commit into from
Jun 17, 2024

Conversation

haydenbaker
Copy link
Contributor

@haydenbaker haydenbaker commented Jun 12, 2024

Background

  • Requests should not have the content-type header added when there is no input shape (and therefore no payload)
    • This doesn't appear to be a case in the aws sdk (operations with no input), but could be in generic clients

Testing

  • Tested by running protocol tests in the typescript sdk

Links


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@haydenbaker haydenbaker requested a review from a team as a code owner June 12, 2024 20:18
@haydenbaker haydenbaker requested a review from sugmanue June 12, 2024 20:18
output: TestNoPayloadInputOutput
}

apply TestNoInputNoPayload @httpRequestTests([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's already the RestJsonNoInputAndOutput test, to which we can add the forbidHeaders.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly, that operation is POST, when it defines no input shape. That probably shouldn't build, or at least a warning should be emitted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, it's better to add a new test here, as the goal of this test is to specifically verify that the content-type header doesn't get set.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key distinction between POST and GET is idempotency rather than the presence of a body. I'm pretty sure we have APIs today that are POST but bind their parameters to the URI/Headers. I'd agree with Hayden this is reasonable to add as a new test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure we have APIs today that are POST but bind their parameters to the URI/Headers

Yeah that's fine because you're sending over data. But when the definition of the operation is such that no data could ever be sent, POST usage is probably a modeling mistake on behalf of the user.

output: TestNoPayloadInputOutput
}

apply TestNoInputNoPayload @httpRequestTests([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key distinction between POST and GET is idempotency rather than the presence of a body. I'm pretty sure we have APIs today that are POST but bind their parameters to the URI/Headers. I'd agree with Hayden this is reasonable to add as a new test.

@haydenbaker haydenbaker merged commit 86e38e0 into main Jun 17, 2024
14 checks passed
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

Successfully merging this pull request may close these issues.

4 participants