Skip to content

fix(importer): close REST response body on HTTP error - #5987

Merged
michaelkedar merged 3 commits into
google:masterfrom
keeltrace:fix/rest-source-close-error-body
Sep 8, 2026
Merged

fix(importer): close REST response body on HTTP error#5987
michaelkedar merged 3 commits into
google:masterfrom
keeltrace:fix/rest-source-close-error-body

Conversation

@keeltrace

Copy link
Copy Markdown
Contributor

Overview

Close the REST source response body before returning an HTTP status error from restSourceRecord.Open.

Fixes#5985

Details

Open returns resp.Body to callers on success, but previously returned early on 4xx/5xx responses without closing it. This closes the body on the error path and adds a regression test using a tracking ReadCloser.

Testing

  • go test -v ./internal/importer -run 'TestRestSourceRecord_Open'
  • go test ./internal/importer
  • git diff --check

AI-assisted contribution: I used an AI coding agent during investigation and implementation. I reviewed the final diff and ran the verification listed above. I am responsible for the submitted change and follow-up.

@michaelkedar

Copy link
Copy Markdown
Member

/gcbrun

@michaelkedarmichaelkedar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, happy to merge if you could fix the lint error

@michaelkedar

Copy link
Copy Markdown
Member

/gcbrun

@michaelkedar
michaelkedar merged commit 540faf3 into google:masterSep 8, 2026
25 checks passed
@keeltrace

Copy link
Copy Markdown
ContributorAuthor

Ty!

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

REST source record leaks response body on HTTP error

2 participants

@keeltrace@michaelkedar