Add W3C Baggage boundary tests and entry-counter comment (follow-up to #1975)#1976
Conversation
Follow-up to open-telemetry#1975. Pins the exact off-by-one behaviour of the W3C Baggage caps that the existing tests (1024 pairs / 500 pairs) only exercised well past the limits: - byte cap is inclusive: 8192 bytes accepted, 8193 bytes rejected - list-member cap: 180 entries accepted, 181st dropped Also documents that $entries counts only ACCEPTED pairs (incremented at the bottom of the loop), not raw comma-separated list-members, so a future change does not silently move the counter and alter semantics. Signed-off-by: tonghuaroot <[email protected]>
|
Thanks for opening your first pull request! If you haven't yet signed our Contributor License Agreement (CLA), then please do so that we can accept your contribution. A link should appear shortly in this PR if you have not already signed one. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1976 +/- ##
============================================
+ Coverage 67.81% 67.86% +0.05%
Complexity 3046 3046
============================================
Files 459 459
Lines 8891 8891
============================================
+ Hits 6029 6034 +5
+ Misses 2862 2857 -5
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 6 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
Fascinating that this failed just PHP 8.1. Did a quick copilot review: Rerunning to test. |
|
Looks like it might have just been a GHA flake, merging. |
Fast-follow to #1975, addressing @bobstrecansky's non-blocking review suggestions.
What's changed
1. Boundary tests (
tests/Unit/API/Baggage/Propagation/ParserTest.php)The existing caps tests fire well past the limits (1024 pairs / 500 pairs), which proves the caps engage but does not pin the
>vs>=edge. These four cases lock the off-by-one against the actual implemented semantics:test_parse_into_accepts_header_at_exactly_w3c_byte_limit— exactly 8192 bytes is accepted (the cap is inclusive:strlen() > MAX_BAGGAGE_BYTES).test_parse_into_rejects_header_one_byte_over_w3c_byte_limit— 8193 bytes discards the whole header.test_parse_into_accepts_exactly_w3c_list_member_limit— 180 valid list-members are all accepted.test_parse_into_caps_at_w3c_list_member_limit_plus_one— the 181st valid member is dropped once$entriesreaches 180 ($entries >= MAX_BAGGAGE_ENTRIES).2. Intent comment (
src/API/Baggage/Propagation/Parser.php)One line documenting that
$entriescounts only accepted pairs (incremented at the bottom of the loop), not raw comma-separated list-members, so the counter isn't silently relocated in a future refactor.The silent-drop observability idea is intentionally deferred — discarding an over-cap header matches the W3C spec ("MAY truncate or discard") and the behaviour of the sibling SDKs, so it's not wired in here.
Testing
vendor/bin/phpunit --filter ParserTest tests/Unit/API/Baggage/Propagation/ParserTest.php