Skip to content

fix(cookie): remove unreachable SameSiteDefaultMode case - #4471

Merged
ReneWerner87 merged 2 commits into
mainfrom
fix/dead-samesite-default-case
Jun 28, 2026
Merged

ReneWerner87 merged 2 commits into
mainfrom
fix/dead-samesite-default-case

Conversation

@ReneWerner87

Copy link
Copy Markdown
Member

Summary

A static analysis run flagged res.go:326 as a dead condition. Verified and confirmed.

In setCookie/Cookie, the first switch maps the Fiber SameSite string onto an http.SameSite value. It only ever produces 0 (disabled), SameSiteLaxMode, SameSiteStrictMode, or SameSiteNoneMode. http.SameSiteDefaultMode (= 1) is never assigned, and nothing mutates sameSite between the two switches.

So the case http.SameSiteDefaultMode in the fasthttp mapping switch was unreachable. The 0 (disabled) value already falls through to default -> fasthttp.CookieSameSiteDisabled, so behavior is unchanged.

Changes

  • Remove the dead case http.SameSiteDefaultMode branch.

No behavior change; build passes.

🤖 Generated with Claude Code

The first switch never assigns http.SameSiteDefaultMode to sameSite, so
the corresponding case in the fasthttp mapping was dead code. The "disabled"
value (0) already falls through to default -> CookieSameSiteDisabled.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 08771ea5-e13c-4e7b-8bf2-2289395b1b2f

📥 Commits

Reviewing files that changed from the base of the PR and between a469916 and 28f84c2.

📒 Files selected for processing (1)
  • res.go
💤 Files with no reviewable changes (1)
  • res.go

Walkthrough

In res.go, the explicit http.SameSiteDefaultMode case is removed from the SameSite switch in DefaultRes.Cookie, causing that mode to fall through to the default branch, which sets CookieSameSiteDisabled.

Changes

SameSite Cookie Handling

Layer / File(s) Summary
Remove SameSiteDefaultMode branch
res.go
Deletes the explicit http.SameSiteDefaultMode case; unrecognized/default modes now resolve to CookieSameSiteDisabled via the default branch.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

A rabbit hopped by with a cookie in paw,
"DefaultMode? No special case—none at all!"
Now it falls to the default, disabled it goes,
Two lines removed, how the clean codebase flows.
🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the change but omits most required template sections, including Fixes #, type of change, and checklist details. Expand the description to follow the template: add Fixes #, fill Changes introduced, Type of change, and the relevant checklist items.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately describes the main change: removing an unreachable SameSiteDefaultMode branch.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dead-samesite-default-case

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

Comment @coderabbitai help to get the list of available commands.

@ReneWerner87 ReneWerner87 added this to v3 Jun 28, 2026
@ReneWerner87 ReneWerner87 added this to the v3 milestone Jun 28, 2026
@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.92%. Comparing base (a469916) to head (34a10c8).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4471      +/-   ##
==========================================
+ Coverage   92.91%   92.92%   +0.01%     
==========================================
  Files         138      138              
  Lines       13570    13568       -2     
==========================================
  Hits        12608    12608              
+ Misses        595      593       -2     
  Partials      367      367              
Flag Coverage Δ
unittests 92.92% <ø> (+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 0ca0741 into main Jun 28, 2026
20 checks passed
@ReneWerner87
ReneWerner87 deleted the fix/dead-samesite-default-case branch June 28, 2026 16:20
@github-project-automation github-project-automation Bot moved this to Done in v3 Jun 28, 2026
@ReneWerner87 ReneWerner87 modified the milestones: v3, v3.4.0 Jul 2, 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.

1 participant