fix(registry/client): surface malformed and non-string error responses (PILOT-132)#10
fix(registry/client): surface malformed and non-string error responses (PILOT-132)#10matthew-pilot wants to merge 1 commit into
Conversation
…s (PILOT-132)
The registry client's sendOnEntry, sendLocked, and sendJSONLocked
treated any valid-JSON response without an "error" key as success,
silently accepting garbage (e.g. {"unexpected":"key"}). Additionally,
only string-typed error values were detected — numeric or object
error values (e.g. {"error":403}) were silently swallowed.
Two changes in each of the three send functions:
1. Broaden error detection to handle any error value type
(resp["error"].(string) → resp["error"] with %v formatting).
2. Add a "type" envelope field check: if a non-empty response lacks
both "error" and "type", it is rejected as malformed. Empty
responses remain valid to preserve backward compatibility with
any edge case.
The rendezvous server always includes a "type" field in its
responses, so this check is a safe defense-in-depth measure.
Closes PILOT-132
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
🛠️ Matthew PR Worker — Status (
|
🛠️ Matthew Explains —
|
Matthew PR Status — #10Title: fix(registry/client): surface malformed and non-string error responses (PILOT-132) TicketsLabels
Files Changed
Next Actions
Auto-generated status check by matthew-pr-worker |
Matthew PR Explain — #10What this PR doesfix(registry/client): surface malformed and non-string error responses (PILOT-132) Scope
TicketsFiles
Review Notes
Auto-generated explain by matthew-pr-worker |
What
The registry client's
sendOnEntry,sendLocked, andsendJSONLockedtreated any valid-JSON response without an"error"key as success, silently accepting garbage responses. Additionally, only string-typed error values were detected — numeric or object error values were silently swallowed.Fix
Two changes in each of the three send functions:
resp["error"].(string)→resp["error"]with%vformatting, so any error value type (string, int, object) is surfaced."error"and"type"keys, it is rejected as malformed. Empty responses remain valid (backward-compatible).The rendezvous server always includes a
"type"field in its responses, so this check is a safe defense-in-depth measure.Verification
go build ./...— ✅ cleango vet ./...— ✅ cleango test ./registry/client/ -count=1 -timeout 60s— ✅ all tests pass (including newTestSendOnEntryReturnsErrorOnNonStringErrorandTestSendReturnsErrorOnMalformedResponse)Diff stat
Closes PILOT-132