Allow opt-in raw Redis responses in Python agent - #1295
Open
Amygos wants to merge 1 commit into
Open
Conversation
Opt-in byte responses let consumers perform strict per-entry decoding without changing existing decoded clients. Assisted-by: Codex:GPT-5
Amygos
force-pushed
the
feat-agent-raw-redis-responses
branch
from
September 4, 2026 11:40
d498e63 to
661cfea
Compare
Amygos
marked this pull request as ready for review
September 4, 2026 11:42
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. |
Member
Author
|
The autogenerated tests have been removed before marking the PR ready to review. |
DavidePrincipi
requested changes
Sep 4, 2026
DavidePrincipi
left a comment
Member
There was a problem hiding this comment.
This PR leaves the previous behavior unchanged. Even if it improves code readability, It is actually a no-op.
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.
Summary
The ns8-metrics module needs to validate publisher-controlled Redis
hashes one key, field, and value at a time.
Previously,
agent.redis_connect()always enabled automatic UTF-8response decoding. A malformed value such as
b"\xff"therefore raisedUnicodeDecodeErrorinsideSCANorHGETALL, before ns8-metrics couldidentify and reject only the invalid publisher entry. This could abort
Prometheus provisioning for all publishers.
This PR adds the keyword-only
decode_responsesargument:decode_responses=Trueremains the default, preserving existingbehavior for all callers.
decode_responses=Falsecreates a genuinely raw Redis connection andreturns unchanged bytes from
scan_iter()andhgetall().existing positional arguments remain unchanged.
The API remains generic and contains no metrics-specific validation.
Related issue
No issue linked yet.
How to test
Run the agent test suite:
cd core/agent bash test-agent.shOn an installed node, verify that the default client returns strings and
that a client created with
decode_responses=Falsereturns bytes fromscan_iter()andhgetall().During development, the behavior was verified against a real Redis
server with malformed UTF-8 in keys, hash fields, and hash values. The
complete existing agent suite passed 32 tests.
Compatibility
Existing modules remain compatible because decoded string responses are
still the default. Consumers must explicitly pass
decode_responses=Falseto receive bytes.A module relying on the new public argument must require an ns8-core
release containing this change or provide a compatibility fallback.
Dependencies
No dependency is required for merging this PR.