Skip modifying User-Agent in ApplyUserAgentStage if the user has already passed custom User-Agent in the request#6614
Merged
Merged
Conversation
65f6dc4 to
05fbba0
Compare
…ady passed custom User-Agent in the request
05fbba0 to
e8b1e16
Compare
dagnir
reviewed
Dec 5, 2025
| "type": "bugfix", | ||
| "category": "AWS SDK for Java v2", | ||
| "contributor": "", | ||
| "description": "Skip User-Agent header modification in ApplyUserAgentStage when custom User-Agent is already provided." |
Contributor
There was a problem hiding this comment.
This is heavy on internal details. Can we simplify so we just say we don't overwrite the custom User-Agent?
Contributor
There was a problem hiding this comment.
Looks the same, forgot to commit the new file perhaps? 😅
dagnir
reviewed
Dec 5, 2025
| public SdkHttpFullRequest.Builder execute(SdkHttpFullRequest.Builder request, | ||
| RequestExecutionContext context) throws Exception { | ||
|
|
||
| if (hasUserAgentInAdditionalHeaders() || hasUserAgentInRequestHeaders(context)) { |
Contributor
There was a problem hiding this comment.
super nit: hasUserAgentInRequestHeaders "inRequestConfig", otherwise it sounds like the header is in the marshalled SdkHttpRequest
dagnir
approved these changes
Dec 5, 2025
|
|
This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Motivation and Context
PR #6513 moved the
ApplyUserAgentStageto execute afterMergeCustomHeadersStage. This caused user-supplied User-Agent headers to be overwritten by the SDK's default User-Agent.Previous behavior: User-supplied User-Agent headers would overwrite the SDK's User-Agent because
ApplyUserAgentStageran beforeMergeCustomHeadersStage.After PR #6513: The SDK's User-Agent now overwrites user-supplied User-Agent headers because
ApplyUserAgentStageruns afterMergeCustomHeadersStage.This PR fixes the issue by skipping User-Agent modification in
ApplyUserAgentStagewhen a custom User-Agent is already provided viaADDITIONAL_HTTP_HEADERS.Modifications
ApplyUserAgentStageto detect if User-Agent header exists inADDITIONAL_HTTP_HEADERSconfigurationTesting
ApplyUserAgentStageTestcovering: - Custom User-Agent preservation - Empty/null User-Agent handling - User-Agent presence in additional headersCustomUserAgentHeaderTestcovering: - Single and multiple custom User-Agent values - API name handling with custom User-Agent - Edge cases (empty, null, list values)mvn installsucceedsTypes of changes
License