Skip to content

fix(commons): keep AWS_SDK_UA_APP_ID idempotent and <=50 chars#5157

Closed
saschabuehrle wants to merge 1 commit intoaws-powertools:mainfrom
saschabuehrle:fix/issue-5082-ua-app-id-limit
Closed

fix(commons): keep AWS_SDK_UA_APP_ID idempotent and <=50 chars#5157
saschabuehrle wants to merge 1 commit intoaws-powertools:mainfrom
saschabuehrle:fix/issue-5082-ua-app-id-limit

Conversation

@saschabuehrle
Copy link
Copy Markdown

Fixes #5082

This patch makes commons user-agent app-id initialization safe for repeated module loads and compliant with the AWS SDK 50-char limit:

  • avoid appending the PT/NO-OP marker when it already exists
  • cap the final AWS_SDK_UA_APP_ID value to 50 chars
  • add regression tests for idempotency and max-length behavior

Greetings, saschabuehrle

@boring-cyborg
Copy link
Copy Markdown

boring-cyborg bot commented Apr 1, 2026

Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need.
In the meantime, check out the #typescript channel on our Powertools for AWS Lambda Discord: Invite link

@powertools-for-aws-oss-automation
Copy link
Copy Markdown

No acknowledgement section found. Please make sure you used the template to open a PR and didn't remove the acknowledgment section. Check the template at .github/PULL_REQUEST_TEMPLATE.md#acknowledgment

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

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

Although I don't have a better solution yet - which is why we haven't addressed the issue - I don't think trimming, slicing, and generally doing all these operations every time the module is imported is the way to go.

I'd rather help customers address the root cause of why the module is imported twice - which is bad regardless of the UA length - or give a way to opt out from UA concatenation altogether.

@dreamorosi dreamorosi added the do-not-merge This item should not be merged label Apr 1, 2026
@saschabuehrle
Copy link
Copy Markdown
Author

Thanks for the detailed review. Agreed on the concern about doing normalization work at import time.

I’m going to rework this around an explicit opt-in/guard path so we avoid repeated module-load mutations and keep behavior predictable. I’ll post an updated patch here.

Greetings, saschabuehrle

@saschabuehrle
Copy link
Copy Markdown
Author

Thanks for the review. I agree this needs a different approach than import-time normalization. I’m parking this one while I work out a cleaner opt-in path and will come back with a revised patch.\n\nGreetings, saschabuehrle

@saschabuehrle
Copy link
Copy Markdown
Author

Closing this out for now since the current approach isn't the right direction. I'll reopen with a new patch once I have a cleaner opt-in design that matches the maintainer guidance.\n\nGreetings, saschabuehrle

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

Labels

do-not-merge This item should not be merged size/M PR between 30-99 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: AWS_SDK_UA_APP_ID can exceed 50-character limit during initialisation

2 participants