Ensure for events containing multiValueHeaders, the Rack::Headers return object is correctly initialised#47
Merged
logandk merged 4 commits intoMay 1, 2026
Conversation
- Check that for both 'regular' and `multiValueHeaders` in event parameter, the return responds to lower-cases keys correctly - Check that for multiValueHeaders, the string literal array hash values are concatenated with `\n` separators
The constructor for `Rack::Headers` is inherited from Hash, so using `.new()` just creates a default value for the hash. Set `parse_headers`'s return value to a correctly initialised instance of Rack::Headers.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #47 +/- ##
=======================================
Coverage 96.81% 96.81%
=======================================
Files 1 1
Lines 314 314
Branches 80 80
=======================================
Hits 304 304
Misses 10 10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
My Rack v3 updates unfortunately introduced a regression; when the event from the AWS ALB contains
multiValueHeaders, theparse_headersmethod was essentially setting a default for theRack::Headersinstance it was returning via the.newconstructor. It goes without saying that this isn't what we want!So we want a) test coverage to check that the
parse_headermethod is doing what it should do and b) make sure to correctly initialise theRack::Headersobject whenmultiValueHeadersare present in the event object.Implementation
I've added unit tests for the
parse_headersmethod; I'm happy with the coverage, and I've implement test-driven-development to make sure it caught the aforementioned issue.The actual fix is easy; don't use
.new, and just use the[]operator to create theRack::Headerinstance instead.Patch version bump
I've opted to bump the version to
2.0.1, as I consider this a straight-forward fix with no additional features.