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

fix(middleware-apply-body-checksum): fix request copying with clone #1324

Merged
merged 3 commits into from
Jul 18, 2024

Conversation

syall
Copy link
Contributor

@syall syall commented Jul 2, 2024

Issue #, if available:

N/A

Description of changes:

Fixed a subtle bug when request copying, otherwise methods like clone() may not be copied over.

If one or more of the packages in the /packages directory has been modified, be sure yarn changeset add has been run and its output has
been committed and included in this pull request. See CONTRIBUTING.md.


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

@syall syall force-pushed the fix-body-checksum-request-clone branch from e225edb to b5e1202 Compare July 2, 2024 12:01
@syall syall marked this pull request as ready for review July 2, 2024 12:14
@syall syall requested review from a team as code owners July 2, 2024 12:14
@syall syall requested a review from hpmellema July 2, 2024 12:14
...headers,
"content-md5": options.base64Encoder(await digest),
},
const cloned = request.clone();
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't a safe assumption.

HttpRequest.isInstance(request) is incorrectly implemented. It only checks that a request is duck-like an HttpRequest interface. The clone method only exists on the HttpRequest class.

It wasn't a good idea naming interfaces and classes the same, even worse that they aren't identical types.

Copy link
Contributor

@kuhe kuhe left a comment

Choose a reason for hiding this comment

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

Note to self: implement static HttpRequest.clone() that accepts HttpRequest interface. Deprecate instance method.

@kuhe kuhe force-pushed the fix-body-checksum-request-clone branch from b5e1202 to f5f42a4 Compare July 15, 2024 18:21
@kuhe
Copy link
Contributor

kuhe commented Jul 18, 2024

This is no longer necessary due to #1345

@kuhe kuhe closed this Jul 18, 2024
@kuhe kuhe reopened this Jul 18, 2024
@kuhe
Copy link
Contributor

kuhe commented Jul 18, 2024

re-opening because this PR is still good for code clarity

@kuhe kuhe merged commit 9624938 into smithy-lang:main Jul 18, 2024
9 of 10 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.

3 participants