Skip to content

fix(lambdaurl): proxy Cookies slice to http.Request header in Wrap#622

Open
mangomaker5 wants to merge 1 commit intoaws:mainfrom
mangomaker5:fix/proxy-lambdaurl-cookies
Open

fix(lambdaurl): proxy Cookies slice to http.Request header in Wrap#622
mangomaker5 wants to merge 1 commit intoaws:mainfrom
mangomaker5:fix/proxy-lambdaurl-cookies

Conversation

@mangomaker5
Copy link
Copy Markdown

Summary

Fixes #597

The Wrap function in lambdaurl converts a LambdaFunctionURLRequest into a standard Go http.Request. Currently, it only proxies cookies found in Headers["cookie"] and completely ignores the dedicated Cookies field on the request struct.

This breaks use cases where stream handlers rely on r.Cookies() and AWS populates the Cookies slice instead of (or in addition to) the cookie header.

Changes

Added logic to proxy request.Cookies entries into the http.Request header, with a guard to prevent duplicate cookie headers when both Headers["cookie"] and Cookies are populated by AWS:

hasCookie := false
for k, v := range request.Headers {
    httpRequest.Header.Add(k, v)
    if strings.ToLower(k) == "cookie" {
        hasCookie = true
    }
}
if !hasCookie {
    for _, cookie := range request.Cookies {
        httpRequest.Header.Add("Cookie", cookie)
    }
}

This follows the same pattern used by aws-lambda-go-api-proxy, as referenced in the original issue.

Testing

  • All existing tests pass (go test -race ./lambdaurl/...)
  • The existing test fixture function-url-request-with-headers-and-cookies-and-text-body.json contains both Headers["cookie"] and Cookies — the hasCookie guard ensures no duplication in this case
  • No changes to test files were needed; existing test coverage already validates this path

Notes

This issue has been open since October 2025 with no maintainer response or linked PRs. Since the fix is minimal (9 lines added, 0 lines removed from logic) and all existing tests pass, I've submitted this to move the conversation forward.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.08%. Comparing base (ca19f6f) to head (53f3f37).

Files with missing lines Patch % Lines
lambdaurl/http_handler.go 66.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #622      +/-   ##
==========================================
- Coverage   75.12%   75.08%   -0.04%     
==========================================
  Files          36       36              
  Lines        1419     1425       +6     
==========================================
+ Hits         1066     1070       +4     
- Misses        274      275       +1     
- Partials       79       80       +1     

☔ 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.

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.

lambdaurl Wrap is not proxying LambdaFunctionURLRequest.Cookies

2 participants