Repository navigation
fix: saveCookieJar wrote every non-secure cookie twice - #5
Merged
Merged
Conversation
A live smoke test (building the real binary, running it against a real local test server, not just the unit test suite) caught this: the saved cookies.json held the same session cookie twice. cookiejar.Jar stores by domain, not by scheme — scheme only gates a Secure-flagged cookie (hidden from an http:// query), it never partitions storage. Querying BOTH "https" and "http" for the same host therefore returned the same non-secure cookie from both queries. "https" alone already returns every cookie (secure or not) a real request to that host would carry. New regression test (TestSaveCookieJarNoDuplicateEntries) reads the raw saved JSON array length directly — the existing roundtrip test didn't catch this because reloading via SetCookies collapses duplicate (name, domain, path) entries back down to one, hiding the bug in the on-disk file. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Caught by a live smoke test after PR #4 merged: building the real
webtestbinary and running it against a real local test server (not just the in-process unit suite) showed the savedcookies.jsonheld the same session cookie twice.Root cause:
cookiejar.Jarstores by domain, not by scheme — scheme only gates aSecure-flagged cookie (hidden from anhttp://query), it never partitions storage.saveCookieJarqueried both"https"and"http"for the same host, so the same non-secure cookie came back from both queries."https"alone already returns every cookie (secure or not) a real request to that host would carry.New regression test (
TestSaveCookieJarNoDuplicateEntries) reads the raw saved JSON array length directly — the existing roundtrip test didn't catch this because reloading viaSetCookiescollapses duplicate(name, domain, path)entries back down to one, hiding the bug in the on-disk file itself.Test plan
TestSaveCookieJarNoDuplicateEntries(new) — fails on the old code, passes now--submitagainst a real local server, confirmed the saved cookie file now has exactly one entry, and a second separateruninvocation still correctly reuses the sessiongo build/go vet/gofmt -l/govulncheck ./...cleango test ./...green (44 tests),go test ./... -raceclean🤖 Generated with Claude Code