Repository navigation
Split CLIENT LIST records on newline only - #4556
Conversation
parse_client_list split the reply with str.splitlines(), which also breaks on \x0b, \x0c, \x1c-\x1e, \x85, \u2028 and \u2029. Those characters are allowed in ACL usernames and unix socket paths, so a single record was cut in two. The as_iter path already split on newline only; the eager path now uses the same generator.
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 @arxhr007, thank you for your contribution!
The fix looks right to me: CLIENT LIST separates records with "\n" only, and reusing _client_list_iter for the eager path makes both paths agree while removing the duplicated split logic. This is good to merge once CI is green.
One optional addition: str.splitlines() also breaks on \r (0x0D), so it would be worth adding it to the parametrized separators in the new test.
|
Thanks for the review. I added |
Description of change
parse_client_listsplits theCLIENT LISTreply withstr.splitlines(). That also breaks on the control characters VT, FF, FS, GS, RS, NEL (U+0085), U+2028 and U+2029, not only on newline. The server does not forbid them inside a field: it only rejects spaces and null characters in ACL usernames, and a Unix-socketaddrcan contain any path character. A record is then cut in two, and the second half comes back as an extra, mostly empty dict._client_list_iter(theas_iter=Truepath) already splits on newline only, so the two paths disagree on the same reply:The eager path now builds its list from
_client_list_iter, so both split the same way and the list of lines is no longer built. It is shared by the sync and async clients, so nothing else needs mirroring. No signature or return type changes.parse_infoandparse_cluster_nodesalso usesplitlines(); I left them alone to keep this to one function.Pull Request check-list
ruff checkandruff format --checkpass on both changed files.pytest tests/test_parserspasses locally (60 passed). The tests that need a Redis server were not run here; CI covers those.test_parse_client_list_only_splits_records_on_newlinecovers VT, FF, CR, FS, GS, RS, NEL, U+2028 and U+2029 for both the eager and theas_iterpath. Without the change tohelpers.pythe 8 cases other than CR fail (the reply comes back as 3 records instead of 2); with it they pass.