fix: use SDK middleware for User-Agent to support AWS_CA_BUNDLE#255
Open
gustavodiaz7722 wants to merge 1 commit into
Open
fix: use SDK middleware for User-Agent to support AWS_CA_BUNDLE#255gustavodiaz7722 wants to merge 1 commit into
gustavodiaz7722 wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: gustavodiaz7722 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
181a627 to
44f7dda
Compare
Previously, the ACK runtime wrapped the *awshttp.BuildableClient in a custom clientWithUserAgent struct to inject a User-Agent header. This broke the AWS SDK's resolveCustomCABundle function, which type-asserts the HTTPClient to *awshttp.BuildableClient to call WithTransportOptions. When AWS_CA_BUNDLE was set, LoadDefaultConfig would fail with: "unable to add custom RootCAs HTTPClient, has no WithTransportOptions, *runtime.clientWithUserAgent" This commit removes the clientWithUserAgent wrapper and instead uses a custom smithy Build middleware to prepend the ACK User-Agent string to outgoing HTTP requests. This approach: 1. Passes *awshttp.BuildableClient directly as the HTTPClient, allowing the SDK to properly modify transport options for CA bundles, proxies, and other features. 2. Preserves the exact User-Agent format (including slashes, parentheses, and semicolons) without character sanitization that the SDK's built-in AddUserAgentKeyValue middleware would apply. 3. Maintains backward compatibility — the User-Agent header seen by AWS APIs is identical to the previous format. Fixes aws-controllers-k8s/community#2915
44f7dda to
3d38de5
Compare
Member
Author
|
/retest |
Member
Author
|
/restest |
Member
Author
|
/retest |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Fixes aws-controllers-k8s/community#2915
When the
AWS_CA_BUNDLEenvironment variable is set, all ACK controllers fail with:Root Cause
The ACK runtime wraps the
*awshttp.BuildableClientin a customclientWithUserAgentstruct to inject User-Agent headers. The AWS SDK'sresolveCustomCABundlefunction type-assertscfg.HTTPClientto*awshttp.BuildableClientin order to callWithTransportOptionsand inject custom root CAs. Since the HTTPClient is*runtime.clientWithUserAgent(not*awshttp.BuildableClient), the assertion fails.Fix
clientWithUserAgentwrapper struct*awshttp.BuildableClientdirectly as the HTTPClient so the SDK can modify its transportawsmiddleware.AddUserAgentKeyValue) throughconfig.WithAPIOptionsThis approach preserves the same User-Agent behavior while making the HTTPClient compatible with all SDK transport modifications (CA bundles, proxies, etc.).
Testing
TestNewAWSConfig_HTTPClient_IsBuildableClient— verifies the HTTPClient remains type-assertable to*awshttp.BuildableClientTestNewAWSConfig_WithAWSCABundle— directly reproduces the original bug by settingAWS_CA_BUNDLEand verifyingLoadDefaultConfigsucceedsBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.