Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mkurz
Copy link
Member

@mkurz mkurz commented Jul 14, 2025

Improvement thanks to

Makes sure that calling attrs(RequestAttrKey.Id) always returns an id, even if the request was rejected by the server backend (before Play parses any headers to set the cookies, etc.)

final def id: Long = attrs(RequestAttrKey.Id)

Also in the light of

it makes a lot of sense to generate and set the request id as early as possible as #13204 will include a timestamp in the id.

@mkurz mkurz force-pushed the request-id_earliest branch 4 times, most recently from e3a9ae1 to 56b0360 Compare July 15, 2025 22:51
@mkurz mkurz force-pushed the request-id_earliest branch from 56b0360 to 1d3ec77 Compare July 15, 2025 23:27
@mkurz
Copy link
Member Author

mkurz commented Jul 16, 2025

As expected the tests I added in first commit failed - and got fixed by the second commit:

[info] PekkoHttpBadClientHandlingSpec
[info] Play should
...
[error]   x allow accessing the raw unparsed path and request-id from an error handler (59 ms)
[error]    500 != 400 (BadClientHandlingSpec.scala:86)
[info] Total for specification PekkoHttpBadClientHandlingSpec
[info] Finished in 21 ms
[info] 4 examples, 1 failure, 0 error
[info] RequestHeaderSpec
[info] request header should
....
[info]   have request id
...
[error]     x not generated if one exists in the attrs already (4 ms)
[error]      85 != 987656789 (RequestHeaderSpec.scala:220)
[info] Total for specification RequestHeaderSpec
[info] Finished in 97 ms
[info] 32 examples, 1 failure, 0 error

It's totally fine to backport as well because default behaviour does not change IMHO.

@mkurz mkurz marked this pull request as ready for review July 16, 2025 10:21
@mkurz mkurz merged commit 702da35 into playframework:main Jul 16, 2025
29 checks passed
@mkurz
Copy link
Member Author

mkurz commented Jul 16, 2025

@Mergifyio backport 2.9.x 3.0.x

@mkurz mkurz deleted the request-id_earliest branch July 16, 2025 10:22
@mergify
Copy link
Contributor

mergify bot commented Jul 16, 2025

backport 2.9.x 3.0.x

✅ Backports have been created

Details

mergify bot added a commit that referenced this pull request Jul 16, 2025
[3.0.x] Generate and set the request-id as early as possible (backport #13409) by @mkurz
mergify bot added a commit that referenced this pull request Jul 16, 2025
[2.9.x] Generate and set the request-id as early as possible (backport #13409) by @mkurz
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