Skip to content

Conversation

@smilkuri
Copy link
Contributor

Issue

#6937

Description

Updates the recursion detection middleware to properly handle case insensitive matching of the X-Amzn-Trace-Id header.

Testing

How was this change tested?
Locally by adding unit test.

RUN  v2.1.9 /local/home/smilkuri/aws-sdk-js-v3/packages/middleware-recursion-detection

✓ src/index.spec.ts (5)
  ✓ recursionDetectionMiddleware (5)
    ✓ sets X-Amzn-Trace-Id header when function name and trace id environmental variables are set
    ✓ should NOT set X-Amzn-Trace-Id header when function name environmental variable is NOT set
    ✓ should NOT set X-Amzn-Trace-Id header when the header is already set
    ✓ should NOT set X-Amzn-Trace-Id header when the header is already set in all lowercase
    ✓ has no effect for browser runtime

Test Files  1 passed (1)
     Tests  5 passed (5)
  Start at  16:05:33
  Duration  315ms (transform 49ms, setup 0ms, collect 44ms, tests 4ms, environment 0ms, prepare 93ms)

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

@smilkuri smilkuri requested a review from a team as a code owner March 19, 2025 18:27
expect(request.headers[TRACE_ID_HEADER_NAME]).toBe("some-real-trace-id");
});

it(`should NOT set ${TRACE_ID_HEADER_NAME} header when the header is already set in all lowercase`, async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

"is already set in all lowercase" should be "is already set with some other casing"

add a couple of test cases with inconsistent casing like x-AmZn-TrAcE-iD

@trivikr trivikr changed the title fix(middleware-recursion-detection): Fix case-insensitive trace ID header detection in middleware fix(middleware-recursion-detection): case-insensitive trace ID header detection in middleware Mar 20, 2025
@smilkuri smilkuri merged commit fcef09e into main Mar 20, 2025
4 checks passed
@smilkuri smilkuri deleted the fix-case-insensitivity branch March 20, 2025 16:35
@github-actions
Copy link

github-actions bot commented Apr 4, 2025

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants