Fix two latent scamp-go bugs: announce-parse panic + Send error swallow#44
Open
riccardo-perotti wants to merge 1 commit into
Open
Fix two latent scamp-go bugs: announce-parse panic + Send error swallow#44riccardo-perotti wants to merge 1 commit into
riccardo-perotti wants to merge 1 commit into
Conversation
Both surfaced during the golangci-lint rollout (dead assignments that hid pre-existing bugs). Bug 1 — newServiceProxy (serviceproxy.go): malformed/short announce data caused index-out-of-range panics (classRecords[0..7] and actionsRawMessages[0..1] were indexed with no length check). Add length guards that return a clean error instead of panicking. Bug 2 — Connection.Send (connection.go): on "use of closed connection" / "broken pipe" write errors the loop broke and Send returned nil, silently losing the message. Propagate a new ErrConnectionClosed sentinel so callers can detect the failure and reconnect/retry. Also early-return on a known-closed connection instead of writing anyway. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
schellj
approved these changes
Jun 12, 2026
schellj
left a comment
Member
There was a problem hiding this comment.
Silent message loss is pretty bad.
Both fixes look good.
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.
Both bugs were uncovered during the golangci-lint rollout (dead-assignment lint hits that were masking pre-existing bugs). Filed as ROP-9250.
Bug 1 —
newServiceProxypanics on malformed announce dataserviceproxy.go: after unmarshaling the announce,classRecords[0..7]and (per action)actionsRawMessages[0..1]were indexed with no length check — short/malformed discovery data → index-out-of-range panic. Added two length guards (classRecords < 8,actionsRawMessages < 2) that return a clean error instead. No behavior change for valid announces.Bug 2 —
Connection.Sendsilently swallows write errors on a dead connconnection.go: on"use of closed connection"/"broken pipe"write errors, the loopbreaked andSendreturnednil→ silent message loss. Now returns a newErrConnectionClosedsentinel (wrapping the underlying error) so callers can detect it and reconnect/retry. Also early-returns on a known-closed connection instead of writing anyway.Sendnow returns an error on dead-conn writesPreviously
Sendreturnednilin these cases. All four in-repo callers already check the error and handle it well, so this is strictly an improvement:requester.go— retries (was: thought it sent, then hung until response-timeout) ✅service.go— closes the dead client ✅client.go/action_options.go— propagate / log ✅Callers wanting to special-case it can use
errors.Is(err, scamp.ErrConnectionClosed).Verification
go build/go vet/go testall pass; golangci-lint (v2.12.2/go1.26) 0 issues.🤖 Generated with Claude Code