Skip to content

fix(common): preserve AWS_SDK_UA_APP_ID environment variable in UserAgentConfigurator - #2762

Open
dhaiirryyaa wants to merge 1 commit into
aws-powertools:mainfrom
dhaiirryyaa:fix/preserve-user-agent-env-var
Open

dhaiirryyaa wants to merge 1 commit into
aws-powertools:mainfrom
dhaiirryyaa:fix/preserve-user-agent-env-var

Conversation

@dhaiirryyaa

Copy link
Copy Markdown

Summary

Changes

When a customer sets the AWS_SDK_UA_APP_ID environment variable in their Lambda environment (rather than setting the sdk.ua.appId Java system property directly), UserAgentConfigurator previously ignored it and set only the Powertools user agent PT/{FEATURE}/{VERSION} PTENV/{ENV}, which overwrote and hid the customer's configured user agent app ID.

This change preserves the user's custom user agent by:

  1. Falling back to the AWS_SDK_UA_APP_ID environment variable if the sdk.ua.appId system property is unset or empty.
  2. Extracting and preserving any user value and concatenating the Powertools identifier while enforcing the 50-character limit.
  3. Adding unit tests in UserAgentConfiguratorTest verifying both environment variable preservation and that system property still takes precedence over the environment variable when both are set.

This aligns behavior with powertools-lambda-typescript (PR #4374).

Issue number: Fixes #2725


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

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: UserAgentConfigurator hides a customer's AWS_SDK_UA_APP_ID environment variable

1 participant