fix: close base64 encoder in DelegatedState.EncodeAsUrlParam#136
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthrough
Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
c482e38 to
d1bf0a3
Compare
…nt data loss The base64.NewEncoder requires Close() to flush any remaining buffered bytes with proper padding. Without it, the final 1-2 bytes of the JSON payload could be silently dropped, producing truncated base64 that fails to decode — breaking the encode/decode round-trip. Found via fuzz testing with FuzzDecodeDelegatedState. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
d1bf0a3 to
abd5877
Compare
Summary
DelegatedState.EncodeAsUrlParam()was not callingClose()on thebase64.NewEncoder, which caused the final buffered bytes to be silently dropped. This produced truncated base64 output that could not be decoded back, breaking the encode/decode round-trip.FuzzDecodeDelegatedStatewhich tests round-trip consistency (encode → decode → encode → decode) and discovered this bug within 3 seconds of fuzzing.Root cause
base64.NewEncoderreturns anio.WriteCloserthat buffers data internally in 3-byte blocks.Close()must be called to flush any remaining 1-2 bytes with proper padding. The original code wrote JSON through the encoder but never closed it, losing trailing bytes.Test plan
FuzzDecodeDelegatedStatepasses (120s, 3M+ executions, no failures)c71785f735fef5eenow passesgolangci-lintpasses with 0 issuesgo test -race ./pkg/...)🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests