Skip to content

Commit 41145a6

Browse files
authored
fix: improve error handling when posting workspace agent version (coder#5775)
A customer ran into an unfortunate error here that we miss!
1 parent 6b68fbb commit 41145a6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

codersdk/workspaceagents.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,15 +489,15 @@ func (c *Client) PostWorkspaceAgentAppHealth(ctx context.Context, req PostWorksp
489489
}
490490

491491
func (c *Client) PostWorkspaceAgentVersion(ctx context.Context, version string) error {
492-
// Phone home and tell the mothership what version we're on.
493492
versionReq := PostWorkspaceAgentVersionRequest{Version: version}
494493
res, err := c.Request(ctx, http.MethodPost, "/api/v2/workspaceagents/me/version", versionReq)
495494
if err != nil {
495+
return err
496+
}
497+
defer res.Body.Close()
498+
if res.StatusCode != http.StatusOK {
496499
return readBodyAsError(res)
497500
}
498-
// Discord the response
499-
_, _ = io.Copy(io.Discard, res.Body)
500-
_ = res.Body.Close()
501501
return nil
502502
}
503503

0 commit comments

Comments
 (0)