Skip to content

Parse boolean OCSP options in connection URLs - #4464

Merged
petyaslavova merged 3 commits into
redis:masterfrom
arieleven:fix/url-decode-responses-bool
Oct 22, 2026
Merged

petyaslavova merged 3 commits into
redis:masterfrom
arieleven:fix/url-decode-responses-bool

Conversation

@arieleven

@arieleven arieleven commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Description of change

Part of #4463. The decode_responses part was split out to #4468 (breaking, for the next major), as requested in review.

from_url() casts query-string options with URL_QUERY_ARGUMENT_PARSERS, and its docstring says boolean options accept "True"/"False" or "Yes"/"No". ssl_validate_ocsp and ssl_validate_ocsp_stapled are missing from that table, so they reach the connection as raw strings:

  • rediss://host?ssl_validate_ocsp=True gives 'True'. The connection checks ssl_validate_ocsp is True, so OCSP validation is silently skipped.
  • rediss://host?ssl_validate_ocsp_stapled=False gives 'False', which turns stapled validation on.

This adds the two keys with to_bool, like the other boolean options. The asyncio SSLConnection has 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:

  • Do tests and lints pass with this change?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?

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_url docstring already describes this behaviour), and no example applies.

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T09:33:45.939582Z fcea07b New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@petyaslavova petyaslavova left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@petyaslavova petyaslavova added maintenance Maintenance (CI, Releases, etc) waiting-for-response labels Oct 20, 2026
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.
@arieleven

Copy link
Copy Markdown
Contributor Author

Thanks, makes sense. I've removed decode_responses from both parser tables and its tests here, so this PR is now only the OCSP options. The decode_responses change is in #4468, to hold for the next major.

@arieleven arieleven changed the title Parse boolean decode_responses and OCSP options in connection URLs Parse boolean OCSP options in connection URLs Oct 20, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 5c3f17c. Configure here.

Comment thread redis/connection.py Resolved

@petyaslavova petyaslavova left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for splitting it out. The OCSP-only change looks good to me. LGTM.

@petyaslavova
petyaslavova merged commit 09a97e1 into redis:master Oct 22, 2026
arieleven added a commit to arieleven/redis-py that referenced this pull request Oct 26, 2026
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Maintenance (CI, Releases, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants