Skip to content

Conversation

@jj22ee
Copy link

@jj22ee jj22ee commented Mar 15, 2025

Issue

#6937

Description

middleware-recursion-detection performs a request header check that is case-sensitive.
This PR changes this check to be case-insensitive.

Testing

Added unit tests.

Also:

  1. Have LambdaX and LambdaY, LambdaX invokes LambdaY via Lambda invoke from @aws-sdk/client-lambda, add permissions to LambdaX to use invoke.
  2. Modified middleware-recursion-detection in node_modules of the LambdaX to make the trace header check case-insensitive
  3. Enable Lambda service traces in both LambdaX and LambdaY
  4. Enable Application Signals in LambdaX both LambdaX and LambdaY
  5. Invoke LambdaX function.
  6. Observed that middleware-recursion-detection will correctly not inject the trace header when calling lambdaClient's invoke, because the x-amzn-trace-id header already exists due to step (4)

Additional context

Add any other context about the PR here.

Checklist

  • If you wrote E2E tests, are they resilient to concurrent I/O?
  • If adding new public functions, did you add the @public tag and enable doc generation on the package?

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

@jj22ee jj22ee requested a review from a team as a code owner March 15, 2025 09:10
@jj22ee jj22ee force-pushed the xray-header-check-fix branch from 6094bba to 0decdae Compare March 15, 2025 09:15
@jj22ee jj22ee force-pushed the xray-header-check-fix branch from 0decdae to 93de1ab Compare March 15, 2025 09:19
@jj22ee jj22ee changed the title fix(middleware-recursion-detection): Make the X-Ray Trace Header check case-insensitive fix(middleware-recursion-detection): make the x-ray trace header check case-insensitive Mar 15, 2025
@jj22ee
Copy link
Author

jj22ee commented Mar 16, 2025

This solution introduces looping through all the keys in the Request Headers, the alternative solution would be to check for both X-Amzn-Trace-Id and x-amzn-trace-id headers.

@jj22ee
Copy link
Author

jj22ee commented Mar 20, 2025

Fixed in #6946

@jj22ee jj22ee closed this Mar 20, 2025
@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.

1 participant