Skip NOT_KEY commands in client tracking#3699
Conversation
While reviewing valkey-io#3675 I found a pre-existing NOT_KEY inconsistency in client tracking: CLUSTERSCAN is skipped by COMMAND GETKEYS/ACL through the key-spec path, but tracking still uses the legacy getKeysFromCommand() Signed-off-by: nmvk <r@nmvk.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesClient Tracking Key Extraction API Update
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/unit/cluster/clusterscan.tcl (1)
43-51: 💤 Low valueConsider adding descriptive error messages to assertions.
The test correctly validates that CLUSTERSCAN does not modify
tracking_total_keys. However, the assertions would benefit from descriptive error messages to aid debugging if they fail.✨ Suggested enhancement
test "CLUSTERSCAN cursor is not tracked by client tracking" { R 0 client tracking on - assert_equal 0 [s 0 tracking_total_keys] + assert_equal 0 [s 0 tracking_total_keys] "Expected tracking_total_keys to be 0 initially" R 0 clusterscan "0-{06S}-0" - assert_equal 0 [s 0 tracking_total_keys] + assert_equal 0 [s 0 tracking_total_keys] "Expected tracking_total_keys to remain 0 after CLUSTERSCAN" R 0 client tracking off }As per coding guidelines, tests should use clear assertions with meaningful error messages.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unit/cluster/clusterscan.tcl` around lines 43 - 51, The assertions in the test "CLUSTERSCAN cursor is not tracked by client tracking" lack descriptive error messages; update the two assert_equal calls that check [s 0 tracking_total_keys] to include clear failure messages (e.g., indicating expected 0 tracking_total_keys before and after R 0 clusterscan "0-{06S}-0"), so if tracking_total_keys changes the assertion output names the test, the expectation, and whether it was before or after the clusterscan call; modify the assert_equal invocations in that test block accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/unit/cluster/clusterscan.tcl`:
- Around line 43-51: The assertions in the test "CLUSTERSCAN cursor is not
tracked by client tracking" lack descriptive error messages; update the two
assert_equal calls that check [s 0 tracking_total_keys] to include clear failure
messages (e.g., indicating expected 0 tracking_total_keys before and after R 0
clusterscan "0-{06S}-0"), so if tracking_total_keys changes the assertion output
names the test, the expectation, and whether it was before or after the
clusterscan call; modify the assert_equal invocations in that test block
accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f1821092-2051-4bc6-aeed-2bb22f38c8b7
📒 Files selected for processing (2)
src/tracking.ctests/unit/cluster/clusterscan.tcl
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## unstable #3699 +/- ##
============================================
- Coverage 76.71% 76.64% -0.08%
============================================
Files 162 162
Lines 80662 80717 +55
============================================
- Hits 61881 61863 -18
- Misses 18781 18854 +73
🚀 New features to boost your workflow:
|
enjoy-binbin
left a comment
There was a problem hiding this comment.
Thanks, LGTM, i actually noticed that too, but did not bother to go deep. You've checked everywhere, and this is the last one, right?
|
Thanks @enjoy-binbin I believe there should not be anything else for
|
Co-authored-by: Madelyn Olson <madelyneolson@gmail.com> Signed-off-by: Madelyn Olson <madelyneolson@gmail.com>
…3675) No bug exists — all NOT_KEY commands (CLUSTERSCAN, SSUBSCRIBE, SPUBLISH, SUNSUBSCRIBE) have NULL getkeys_proc, so doesCommandHaveKeys returns 0 and ACL correctly skips key checks. This PR makes the handling more explicit and defensive for future commands that may combine getkeys_proc with NOT_KEY key-specs. Changes: - Refactor doesCommandHaveKeys() from a one-line ternary into clearer if-else branches. Add an explicit check: if a command has getkeys_proc but all its key-specs are NOT_KEY, treat it as having no real keys. - Add a defensive NOT_KEY check in ACLSelectorCheckKey() to skip key-pattern ACL validation for NOT_KEY entries, consistent with the existing skip in getKeysUsingKeySpecs(). - Add tests: verify COMMAND GETKEYS/GETKEYSANDFLAGS report "no key arguments" for NOT_KEY commands; verify restricted ACL users can run CLUSTERSCAN without key-permission errors. Related: #2934, #3699 Signed-off-by: Binbin <binloveplay1314@qq.com>
While reviewing #3675 I found a pre-existing
NOT_KEYinconsistency in client tracking.CLUSTERSCANis skipped byCOMMAND GETKEYS/ACLthrough the key spec path, but tracking still usesgetKeysFromCommand(). Updated to usegetKeysFromCommandWithSpecsThis affects today
CLUSTERSCANbecause it is RO,SPUBLISH/SSUBSCRIBE/SUNSUBSCRIBEusingNOT_KEYare not RO.