fix: drain Identity error body (keep-alive); reject whitespace-only credential fields in form

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-04 20:36:50 +07:00
parent be408a216c
commit e8e7371f09
3 changed files with 26 additions and 3 deletions
+3
View File
@@ -118,6 +118,9 @@ func (c *Client) authenticate(ctx context.Context, cr Creds) (string, time.Time,
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusCreated && resp.StatusCode != http.StatusOK {
// Drain the body so the underlying connection can be reused by the
// transport's keep-alive pool; the error itself stays generic.
io.Copy(io.Discard, resp.Body)
return "", time.Time{}, fmt.Errorf("selectel: identity auth failed: %d", resp.StatusCode)
}
tok := resp.Header.Get("X-Subject-Token")