Skip to content

Ensure for events containing multiValueHeaders, the Rack::Headers return object is correctly initialised#47

Merged
logandk merged 4 commits into
logandk:masterfrom
university-of-york:patching-multivaluedheaders-issues
May 1, 2026
Merged

Ensure for events containing multiValueHeaders, the Rack::Headers return object is correctly initialised#47
logandk merged 4 commits into
logandk:masterfrom
university-of-york:patching-multivaluedheaders-issues

Conversation

@MatthewPickinYork

@MatthewPickinYork MatthewPickinYork commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Context

My Rack v3 updates unfortunately introduced a regression; when the event from the AWS ALB contains multiValueHeaders, the parse_headers method was essentially setting a default for the Rack::Headers instance it was returning via the .new constructor. It goes without saying that this isn't what we want!

So we want a) test coverage to check that the parse_header method is doing what it should do and b) make sure to correctly initialise the Rack::Headers object when multiValueHeaders are present in the event object.

Implementation

I've added unit tests for the parse_headers method; 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 the Rack::Header instance 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.

- 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

codecov Bot commented Apr 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.81%. Comparing base (dd36f13) to head (931dfd5).
⚠️ Report is 5 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@logandk
logandk merged commit 3beece2 into logandk:master May 1, 2026
5 checks passed
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.

2 participants