fix: Fix panic on a malformed server cookie#491
Draft
Pijukatel wants to merge 4 commits into
Draft
Conversation
`set_cookies` runs inside reqwest's cookie-store callback, a Rust callback driven by the HTTP stack. The `.unwrap()`s on the cookie constructor and `set_cookie` call meant a hostile/buggy server's malformed `Set-Cookie` (bad domain/expiry that `http.cookiejar.Cookie` rejects), or a custom cookie jar whose `set_cookie` raises, would panic and unwind across the FFI boundary — aborting the host process instead of raising a catchable exception. Mirror the Node wrapper's behavior of skipping cookies the jar rejects, but emit a Python `UserWarning` (falling back to stderr) so the dropped cookie is surfaced rather than silently ignored. Closes #478 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015p2biLkkRLNEs9xWyqdpby
`set_cookies` runs inside reqwest's cookie-store callback, a Rust callback driven by the HTTP stack. The `.unwrap()`s on the cookie constructor and `set_cookie` call meant a hostile/buggy server's malformed `Set-Cookie` (bad domain/expiry that `http.cookiejar.Cookie` rejects), or a custom cookie jar whose `set_cookie` raises, would panic and unwind across the FFI boundary — aborting the host process instead of raising a catchable exception. Skip the offending cookie and continue, ignoring parsing errors silently to match the Node binding's `setCookie` handling in `index.wrapper.js`. Closes #478 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015p2biLkkRLNEs9xWyqdpby
Add a regression test (sync and async) for #478: a custom cookie jar whose `set_cookie` raises must not abort the interpreter. The request completes, the offending cookie is skipped, and a valid cookie in the same response is still stored. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015p2biLkkRLNEs9xWyqdpby
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.
Malformed cookies are silently ignored like in JS version.