-
Notifications
You must be signed in to change notification settings - Fork 4
Handle discarded io.ReadAll errors in client.go #103
Description
Problem
There are 12 instances of body, _ := io.ReadAll(resp.Body) in internal/devlake/client.go. The error from io.ReadAll is silently discarded.
If the TCP connection resets mid-response (possible with flaky networks, Azure Container Instances timing out, or proxy interruptions), this produces an empty or truncated body, which then fails with a confusing json.Unmarshal error:
unexpected end of JSON input
Instead of a clear:
reading response body: connection reset by peer
Fix
Replace all 12 instances of:
go body, _ := io.ReadAll(resp.Body)
With:
go body, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("reading response: %w", err) }
For functions that return error only (DeleteConnection, DeleteScope, DeleteProject), adjust the return accordingly.
Acceptance Criteria
- All
io.ReadAllcalls inclient.gohandle errors - Error messages clearly indicate "reading response" vs "parsing JSON"
-
go build ./...andgo test ./...pass