Skip to content

bug: fix malformed date in Bedrock AssumeRole session name#1728

Open
Lyqed wants to merge 1 commit into
Portkey-AI:mainfrom
Lyqed:fix/bedrock-assume-role-session-name-date
Open

bug: fix malformed date in Bedrock AssumeRole session name#1728
Lyqed wants to merge 1 commit into
Portkey-AI:mainfrom
Lyqed:fix/bedrock-assume-role-session-name-date

Conversation

@Lyqed

@Lyqed Lyqed commented Jul 10, 2026

Copy link
Copy Markdown

Description: (required)

  • getAssumedRoleCredentials builds the STS RoleSessionName from ${date.getFullYear()}${date.getMonth()}${date.getDay()}. getMonth() is zero-indexed and getDay() returns the day of the week, not the day of the month, so the session name is a malformed date: 202665 on 2026-07-10, and 202706 on 2027-01-02, which reads as a mid-2027 date.
  • The session name is not cosmetic: it appears in CloudTrail events and in the AWS CUR line-item identity column for every Bedrock call made with the assumed role, so the malformed value lands in audit and billing data.
  • Fixed to the unambiguous zero-padded YYYYMMDD form via date.toISOString().slice(0, 10).replace(/-/g, '').
  • No behavior change beyond the string value: the session name is not part of the credential cache key (${awsRoleArn}/${awsExternalId}/${awsRegion}), and the new value passes the STS RoleSessionName charset/length constraints ([\w+=,.@-]{2,64}).

Tests Run/Test cases added: (required)

  • Verified old vs new values:
    Jan 2, 2027  old: 202706  new: 20270102
    Jul 10, 2026 old: 202665  new: 20260710
    valid session name charset/length: true
    
    (There is no existing unit test coverage for src/providers/bedrock/utils.ts; happy to add a test if you can point me at the preferred harness for provider utils.)

Type of Change:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)

getMonth() is zero-indexed and getDay() returns day-of-week, so the
RoleSessionName came out as e.g. 202665 for 2026-07-10, and 202706
for 2027-01-02 (which reads as a mid-2027 date). Use the padded
YYYYMMDD form instead. The session name is visible in CloudTrail and
the CUR line-item identity, so the malformed value ends up in audit
and billing data.
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.

1 participant