Skip to content

Preserve explicit None for client metadata config#4081

Merged
petyaslavova merged 3 commits into
masterfrom
ps_allow_set_client_info_to_be_optional
May 27, 2026
Merged

Preserve explicit None for client metadata config#4081
petyaslavova merged 3 commits into
masterfrom
ps_allow_set_client_info_to_be_optional

Conversation

@petyaslavova
Copy link
Copy Markdown
Collaborator

@petyaslavova petyaslavova commented May 26, 2026

Commit d411a47 introduced DriverInfo for CLIENT SETINFO metadata, but it also made omitted metadata values indistinguishable from values explicitly set to None. That meant users could no longer pass None to disable client metadata setup, because None was resolved into the default redis-py name/version before connection setup.

This change introduces a shared SENTINEL marker for omitted arguments and uses it for driver_info, lib_name, and lib_version across sync, async, and cluster client paths. Omitted values still resolve to the previous defaults (redis-py and the installed redis-py version), while explicit None is preserved. When driver_info=None, or both legacy metadata values are explicitly None, the resolved config remains None so CLIENT SETINFO is skipped.

The shared sentinel lives in redis.utils, and redis._parsers.socket.SENTINEL now re-exports the same object to preserve compatibility with existing internal/library imports from the older path. Sync cluster kwargs were also updated to allow driver_info through the existing cleanup path.

Tests were added for default resolution, explicit None behavior, shared sentinel compatibility, client-level propagation, and sync/async connection handshakes that should skip CLIENT SETINFO when metadata is disabled.


Note

Low Risk
Behavior change is limited to client metadata resolution and connection handshake SETINFO; defaults for omitted args stay the same, with tests covering explicit None and skip paths.

Overview
Introduces a shared SENTINEL marker in redis.utils (re-exported from redis._parsers.socket for compatibility) so omitted driver_info / lib_name / lib_version arguments are distinct from explicit None.

Sync, async, cluster, and connection constructors now default those parameters to SENTINEL instead of None. resolve_driver_info and DriverInfo only apply the usual redis-py defaults when values are omitted; explicit None is preserved so CLIENT SETINFO is skipped on connect. Cluster client kwargs were updated to pass driver_info through the existing cleanup path.

Tests cover default resolution, explicit-None propagation, sentinel identity, and sync/async handshakes that must not send SETINFO when metadata is disabled.

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

@jit-ci
Copy link
Copy Markdown

jit-ci Bot commented May 26, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@petyaslavova petyaslavova merged commit 6ad0c09 into master May 27, 2026
343 checks passed
@petyaslavova petyaslavova deleted the ps_allow_set_client_info_to_be_optional branch May 27, 2026 11:09
petyaslavova added a commit that referenced this pull request May 27, 2026
* Preserve explicit None for client metadata config

* Fixing linters after conflict resolution via web interface
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants