Skip to content

Parse boolean decode_responses in connection URLs (breaking, for the next major) - #4468

Open
arieleven wants to merge 1 commit into
redis:masterfrom
arieleven:fix/url-decode-responses-major
Open

arieleven wants to merge 1 commit into
redis:masterfrom
arieleven:fix/url-decode-responses-major

Conversation

@arieleven

@arieleven arieleven commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Description of change

Split out of #4464 at the maintainer's request, to hold for the next major release. Part of #4463.

from_url() casts query-string options with URL_QUERY_ARGUMENT_PARSERS, and its docstring says boolean options accept "True"/"False" or "Yes"/"No". decode_responses is missing from that table (sync and asyncio), so it reaches the connection as a raw string and ?decode_responses=False (or 0/no) turns decoding on:

r = redis.Redis.from_url("redis://localhost/0?decode_responses=false")
r.get_encoder().decode(b"x")  # 'x' today, b'x' expected

This adds decode_responses with to_bool to both tables, like the other boolean options.

Breaking change: anyone whose URL sets decode_responses=False (or 0/no) gets str replies today and will get bytes after this change, which is why it is kept out of #4464.

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.

The new tests are in the existing URL parsing test classes (sync and asyncio) and fail without the change; the URL parsing tests and ruff pass locally. Fork CI not run for this branch yet. No API change, so no documentation update (the from_url docstring already describes this behaviour), and no example applies.


Note

Medium Risk
Behavior change for anyone relying on URL decode_responses=false/no/0 today; response type (str vs bytes) flips for those clients at upgrade.

Overview
decode_responses in ConnectionPool.from_url / Redis.from_url query strings is now parsed with to_bool, matching other boolean URL options in sync and asyncio (redis/connection.py, redis/asyncio/connection.py). Values like False, 0, and no become real False instead of staying as strings (where e.g. "False" behaved like enabled decoding).

Breaking (next major): URLs that set decode_responses=False (or similar “off” spellings) currently get decoded str replies because the flag was mis-handled; after this change they get bytes as intended.

Sync and asyncio connection-pool tests assert connection_kwargs and get_encoder().decode_responses for ?decode_responses=False and ?decode_responses=Yes.

Reviewed by Cursor Bugbot for commit 5bfb945. Bugbot is set up for automated code reviews on this repo. Configure here.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 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-26T21:24:49.424427Z 5bfb945 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 added the breakingchange API or Breaking Change label Oct 22, 2026

@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!

Thanks for splitting this out of #4464. The change looks good: it uses the same to_bool parsing as the other boolean URL options, it's mirrored in both stacks, and since it goes through parse_url the cluster clients get the fix too.

Because it changes replies from str to bytes for URLs with decode_responses=False today, I'm labeling it as a breaking change and holding it for the next major release. No changes are needed now. Once #4464 is merged, this branch will need a quick rebase for the one-line conflict in redis/connection.py.

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).
@arieleven
arieleven force-pushed the fix/url-decode-responses-major branch from 8f0a7df to 5bfb945 Compare October 26, 2026 21:22
@arieleven

Copy link
Copy Markdown
Contributor Author

Rebased on current master (1923fb27) now that #4464 is in. No conflicts; the URL tests pass and the two new tests still fail without the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breakingchange API or Breaking Change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants