[Feature] Do not silently discard integer parse errors in CLUSTER INFO / CLUSTER NODES parsing
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 62/100
Research direction
Start in internal/redis/client.go with GetClusterInfo and ParseClusterNodesOutput, then read the existing parser tests. Decide and document whether each malformed integer is warn-and-skip or propagated as an error, keeping valid-output behavior unchanged. Add malformed-input tests that verify warnings or errors, defined zero-value fallback, and no panic.
Written by the indexing model from the issue text.
Description
Problem
Robin's Redis client parses CLUSTER INFO and CLUSTER NODES output and silently discards strconv.Atoi errors, defaulting the field to 0 (internal/redis/client.go):
// GetClusterInfo
case "cluster_slots_ok":
info.SlotsOK, _ = strconv.Atoi(value)
case "cluster_slots_fail":
info.SlotsFail, _ = strconv.Atoi(value)
case "cluster_known_nodes":
info.KnownNodes, _ = strconv.Atoi(value)
case "cluster_size":
info.ClusterSize, _ = strconv.Atoi(value)
// ParseClusterNodesOutput
pingSent, _ := strconv.Atoi(parts[4])
pongRecv, _ := strconv.Atoi(parts[5])
epoch, _ := strconv.Atoi(parts[6])
In practice this is low impact — Redis reliably returns integers for these fields, and a 0 fallback is usually conservative (e.g. SlotsOK == 0 != 16384 makes the cluster look "not ready", triggering retries rather than a false-healthy result or data corruption). The real drawback is that a malformed response would be swallowed silently: a wrong value with no log and no signal, making diagnosis hard if it ever happens.
Proposed solution
Make parse failures observable instead of silent. Suggested approach:
- On
Atoifailure, log a warning including the raw field/value and node address, and skip the field (keep the zero value) rather than dropping the error on the floor. - For the health-relevant
CLUSTER INFOfields (cluster_slots_ok,cluster_slots_fail,cluster_known_nodes,cluster_size), consider propagating an error fromGetClusterInfo(it already returnserror) so a genuinely malformed cluster-state response surfaces to the caller instead of being masked as0. - For the informational
CLUSTER NODESfields (PingSent,PongRecv,Epoch), a warning-and-skip is sufficient; propagating an error would require changingParseClusterNodesOutput's signature (currently returns only[]ClusterNode) — decide during implementation whether that's warranted.
Acceptance criteria
-
Atoifailures inGetClusterInfoandParseClusterNodesOutputare logged (warning) with enough context (field name, raw value, node address) instead of silently discarded. - Decision documented per field: warn-and-skip vs. error propagation. At minimum,
cluster_slots_okfailures are surfaced (log and/or error). - No behavior change on well-formed Redis output (existing parse tests still pass).
- Unit tests cover malformed input for both parsers (non-numeric field ⇒ logged, no panic, defined fallback).
Implementation notes
GetClusterInfoalready returnserror, so propagating is cheap there if chosen.ParseClusterNodesOutputis a free function returning[]ClusterNode; changing it to also return an error touchesGetClusterNodesand its callers — keep scope in mind, warn-and-skip may be the pragmatic choice.- Keep a logger available in the client (or pass one) so the parser can emit the warning.
Severity
Low — robustness/observability improvement, not a fix for an active bug. Redis returns valid integers in normal operation; this hardens against malformed/corrupt responses and makes them diagnosable.
- Dominant language
- Go
- Stars
- 18
- Forks
- 0
- Avg merge
- 11h 16m
- Merged PRs (30d)
- 11
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from InditexTech/redkey-robin
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 55/100
InditexTech/redkey-robin#81 ·
Maintainers usually reply within 1 day
-
[Bug] Stale series for string-valued INFO metrics (e.g. `redkey_version`) after the value changesOpenbug
Difficulty 4/5 3-5 days Newbie friendliness 55/100
InditexTech/redkey-robin#76 ·
Maintainers usually reply within 1 day
-
[Bug] Rolling N+1 upgrade stalls indefinitely when a `redis-cli --cluster reshard` does not finishOpenenhancement
Difficulty 4/5 3-5 days Newbie friendliness 57/100
InditexTech/redkey-robin#70 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 22/100
InditexTech/redkey-robin#68 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 68/100
InditexTech/redkey-robin#44 ·
Maintainers usually reply within 1 day
All issues in InditexTech/redkey-robin
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
coder/openstorage#807 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
coder/coder-logstream-kube#255 · 1 comment ·
-
[FEATURE]: 录入 AIDEV Agent Package v1 接入参考文档Possibly taken A pull request linked to this issue is open or already merged. Openkind/features
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
TencentBlueKing/bk-nodemgr#3991 ·
Maintainers usually reply within 1 day