🐛 bug: Remove Flash Cookie from Response headers after parsing#3840
🐛 bug: Remove Flash Cookie from Response headers after parsing#3840
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughThe changes add cookie cleanup logic to the flash message parsing function, ensuring the Flash cookie is deleted after successful parsing. Corresponding test assertions were added to verify the cookie expiration in response headers across redirect operations. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (1)**/*.go📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (7)📓 Common learnings📚 Learning: 2024-07-02T13:29:56.992ZApplied to files:
📚 Learning: 2024-10-08T19:06:06.583ZApplied to files:
📚 Learning: 2025-10-16T07:19:52.418ZApplied to files:
📚 Learning: 2024-12-13T08:14:22.851ZApplied to files:
📚 Learning: 2024-07-26T21:00:12.902ZApplied to files:
📚 Learning: 2024-09-25T15:57:10.221ZApplied to files:
🧬 Code graph analysis (2)redirect_test.go (2)
redirect.go (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (4)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3840 +/- ##
=======================================
Coverage 92.18% 92.18%
=======================================
Files 115 115
Lines 9753 9754 +1
=======================================
+ Hits 8991 8992 +1
Misses 484 484
Partials 278 278
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
/gemini review |
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the flash message cookie parsing logic to improve performance by avoiding unnecessary byte operations. The key change is passing the cookie value directly as a parameter to parseAndClearFlashMessages() instead of retrieving it within the function.
Key changes:
- Modified
parseAndClearFlashMessages()to accept cookie value as a parameter - Removed the
bytespackage import fromrouter.goas it's no longer needed - Updated flash message detection to use
Cookies()method instead of checking raw headers withbytes.Contains()
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| router.go | Removed bytes import; refactored flash cookie detection to retrieve cookie value before calling parseAndClearFlashMessages() |
| redirect.go | Modified parseAndClearFlashMessages() to accept cookieValue parameter and added early return for empty values |
| redirect_test.go | Updated all test and benchmark calls to parseAndClearFlashMessages() to pass the cookie value as a parameter |
There was a problem hiding this comment.
Code Review
This pull request introduces a significant performance improvement for flash cookie parsing by replacing an inefficient raw header scan with a direct cookie lookup. The refactoring of parseAndClearFlashMessages is well-executed, making the code cleaner and more testable. The accompanying test updates are appropriate. I have one suggestion to address a potential bug in the flash message handling logic to ensure they are cleared after being read.
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.
| Benchmark suite | Current: e9872ac | Previous: bc74824 | Ratio |
|---|---|---|---|
Benchmark_Redirect_parseAndClearFlashMessages |
868.7 ns/op 192 B/op 7 allocs/op |
543.2 ns/op 192 B/op 7 allocs/op |
1.60 |
Benchmark_Redirect_parseAndClearFlashMessages - ns/op |
868.7 ns/op |
543.2 ns/op |
1.60 |
Benchmark_Compress/Zstd - B/op |
1 B/op |
0 B/op |
+∞ |
This comment was automatically generated by workflow using github-action-benchmark.

Summary