Repository navigation
Parse boolean OCSP options in connection URLs - #4464
Conversation
from_url() casts query arguments with URL_QUERY_ARGUMENT_PARSERS, but decode_responses, ssl_validate_ocsp and ssl_validate_ocsp_stapled were missing from it and reached the connection as raw strings. So ?decode_responses=False turned decoding on, ?ssl_validate_ocsp=True skipped OCSP validation (the check is `is True`), and ?ssl_validate_ocsp_stapled=False turned stapled validation on. Parse them with to_bool like the other boolean options. The asyncio SSLConnection has no OCSP options, so only decode_responses is added there.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
petyaslavova
left a comment
There was a problem hiding this comment.
Hey @taltal-beep, thank you for your contribution!
The OCSP part is a clear fix: ssl_validate_ocsp=True is silently ignored today and ssl_validate_ocsp_stapled=False turns stapling on, so I'd like to merge that. The decode_responses part is also a real bug, but fixing it changes replies from str to bytes for anyone whose URL has decode_responses=False (or 0/no) today, and their code currently works with str. That makes it a breaking change, so it can only go into the next major release.
Please remove decode_responses from both parser tables and its tests here, and open a separate PR for it that we can hold for the next major. Everything else looks ready.
Parsing decode_responses with to_bool changes replies from str to bytes for URLs that set decode_responses=False today, so it is a breaking change. Keep only the OCSP options here, as requested in review; the decode_responses change moves to its own PR for the next major release.
|
Thanks, makes sense. I've removed |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 5c3f17c. Configure here.
petyaslavova
left a comment
There was a problem hiding this comment.
Thanks for splitting it out. The OCSP-only change looks good to me. LGTM.
from_url() casts query arguments with URL_QUERY_ARGUMENT_PARSERS, but decode_responses was missing from it and reached the connection as a raw string, so ?decode_responses=False (or 0/no) turned decoding on. Parse it with to_bool like the other boolean options, in both the sync and asyncio parser tables. This changes replies from str to bytes for URLs that set decode_responses=False today, so it is meant for the next major release (split out of redis#4464 at the maintainer's request).

Description of change
Part of #4463. The
decode_responsespart was split out to #4468 (breaking, for the next major), as requested in review.from_url()casts query-string options withURL_QUERY_ARGUMENT_PARSERS, and its docstring says boolean options accept "True"/"False" or "Yes"/"No".ssl_validate_ocspandssl_validate_ocsp_stapledare missing from that table, so they reach the connection as raw strings:rediss://host?ssl_validate_ocsp=Truegives'True'. The connection checksssl_validate_ocsp is True, so OCSP validation is silently skipped.rediss://host?ssl_validate_ocsp_stapled=Falsegives'False', which turns stapled validation on.This adds the two keys with
to_bool, like the other boolean options. The asyncioSSLConnectionhas no OCSP options, so the asyncio table is unchanged. The new test is in the existing SSL URL parsing test class and fails without the change.Pull Request check-list
Please make sure to review and check all of these items:
NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.
CI on the fork: https://github.com/taltal-beep/redis-py/actions/runs/39296553332. No API change, so no documentation update is needed (the
from_urldocstring already describes this behaviour), and no example applies.