8000 🐛 bug: unbracket IPv6 literals without port in CookieJar by helmipradita · Pull Request #4877 · gofiber/fiber · GitHub
[go: up one dir, main page]

Skip to content

🐛 bug: unbracket IPv6 literals without port in CookieJar - #4877

Merged
ReneWerner87 merged 1 commit into
gofiber:mainfrom
helmipradita:fix/cookiejar-ipv6-host-normalization
Nov 13, 2026
Merged

ReneWerner87 merged 1 commit into
gofiber:mainfrom
helmipradita:fix/cookiejar-ipv6-host-normalization

Conversation

@helmipradita
@helmipradita helmipradita commented Nov 12, 2026 •
Copy link
Copy Markdown
Contributor

Description

normalizeCookieHost in client/cookiejar.go strips brackets from IPv6 literals only when a port is present (because utils.SplitHostPort unbrackets "[::1]:8080" into "::1", while "[::1]" returns ok == false and keeps the brackets). As a result, cookies stored from a host with a port did not match lookups for the same IPv6 host without a port, and vice versa.

This unbrackets enclosing [...] in normalizeCookieHost when utils.SplitHostPort does not match, keeping storage and lookup keys consistent regardless of port presence.

Refs #4604

Changes introduced

  • Bug fix (non-breaking change which fixes an issue)

  • Strip surrounding [ / ] in normalizeCookieHost when utils.SplitHostPort returns ok == false.

  • Extend Test_CookieJar_NormalizedHostPaths with IPv6 bracketed/unbracketed port transitions.

Checklist

  • Conducted a self-review of the code and provided comments for complex or critical parts.
  • Added or updated unit tests to validate the effectiveness of the changes or new features.
  • Ensured that new and existing unit tests pass locally with the changes.
  • Aimed for optimal performance with minimal allocations in the new code.

🤖 Maintainers: /generate re-runs the code generators on this branch

Signed-off-by: Helmi Pradita <helmipraditaa@gmail.com>
@coderabbitai
coderabbitai Bot commented Nov 12, 2026 •
Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

normalizeCookieHost now removes surrounding brackets from IPv6 literals when host-port parsing does not apply. Tests cover cookie retrieval across IPv6 host forms that differ by port, brackets, or hexadecimal case.

Changes

IPv6 cookie host normalization

Layer / File(s) Summary
Normalize IPv6 hosts and verify lookups
client/cookiejar.go, client/cookiejar_test.go
normalizeCookieHost removes surrounding brackets from IPv6 literals when host-port parsing does not apply. Tests check retrieval of manually set and response cookies across alternate IPv6 host forms.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • gofiber/fiber#4844: Adds normalizeCookieHost, which this change updates to handle bracketed IPv6 hosts.

Suggested labels: ☢️ Bug

Suggested reviewers: anqorithm

Merge Risk: Minimal · up to baeb6

This change makes cookies for IPv6 hosts match consistently whether or not the host is written with brackets or a port. No merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: IPv6 literals without a port are unbracketed in CookieJar. The raw summary says normalizeCookieHost now strips brackets from IPv6 literals when host-port parsing does …
Description check Passed The description covers the problem, the fix, and the test changes. It states the bug fix type and includes a checked self-review, unit test, and local test checklist items. It links the issue as 'Refs…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: IPv6 literals without a port are unbracketed in CookieJar. The raw summary says normalizeCookieHost now strips brackets from IPv6 literals when host-port parsing does not apply, and the tests cover bracketed and unbracketed IPv6 port transitions. The title uses an emoji prefix and a 'bug:' label, which is acceptable under the commit convention and does not make it misleading.

Full details: Description check

Explanation

The description covers the problem, the fix, and the test changes. It states the bug fix type and includes a checked self-review, unit test, and local test checklist items. It links the issue as 'Refs #4604' rather than the template's 'Fixes # (issue)' line. Several template sections are absent: Benchmarks, Documentation Update, Changelog, Migration Guide, Express API alignment, API Longevity, and Examples. The Type of change list also omits the other categories, which is expected. The checklist omits the docs update and benchmark items, though the description does say performance was considered. Overall the description is mostly complete for a low-effort bug fix, so it passes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks each host with care
Brackets lift from IPv6 air
Port and case may change their place
Cookies still return from every trace
The bunny hops, its jar in tow

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d3046de1-fe4e-4d37-899c-37ef5ed09dbd
Commits

Reviewing files that changed from the base of the PR and between cabc1fd and baeb621.

Files selected for processing: 2

  • client/cookiejar.go
  • client/cookiejar_test.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@ReneWerner87 ReneWerner87 added this to v3 Nov 12, 2026
@ReneWerner87 ReneWerner87 added this to the v3 milestone Nov 12, 2026
@codecov
codecov Bot commented Nov 12, 2026
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.04%. Comparing base (65a431e) to head (baeb621).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4877      +/-   ##
==========================================
+ Coverage   96.02%   96.04%   +0.01%     
==========================================
  Files         156      156              
  Lines       20012    20014       +2     
==========================================
+ Hits        19217    19222       +5     
+ Misses        483      481       -2     
+ Partials      312      311       -1     
Flag Coverage Δ
unittests 96.04% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

@ReneWerner87
ReneWerner87 merged commit fa31f19 into gofiber:main Nov 13, 2026
30 checks passed
@github-project-automation github-project-automation Bot moved this to Done in v3 Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants

0