Skip to content

Drop SetDoNotParseResponse in fetchURL -- connection leak#184

Open
mclaughlin-thomas wants to merge 1 commit intoOutSystems:mainfrom
mclaughlin-thomas:main
Open

Drop SetDoNotParseResponse in fetchURL -- connection leak#184
mclaughlin-thomas wants to merge 1 commit intoOutSystems:mainfrom
mclaughlin-thomas:main

Conversation

@mclaughlin-thomas
Copy link
Copy Markdown

The function fetchURL() only reads the response status and Location header -- it does not touch the body. SetDoNotParseResponse(true) tells resty not to drain or close the body for us, transferring that responsibility to the caller.

// SetDoNotParseResponse method instructs Resty not to parse the response body automatically.
// Resty exposes the raw response body as [io.ReadCloser]. If you use it, do not
// forget to close the body, otherwise, you might get into connection leaks, and connection
// reuse may not happen.
//
// NOTE: [Response] middlewares are not executed using this option. You have
// taken over the control of response parsing from Resty.
func (c *Client) SetDoNotParseResponse(notParse bool) *Client {
	c.notParseResponse = notParse
	return c
}

Since we never close it, the body and its underlying socket stay open.

Removing the option lets resty handle body cleanup on its normal path.
No behavior change for callers; existing tests still pass.

If SetDoNotParseResponse is needed, that close can be added explicitly instead:

...
	resp, err := client.SetDoNotParseResponse(true).R().Get(requestLocation)
	if resp != nil {
		if body := resp.RawBody(); body != nil {
			defer body.Close()
		}
	}

...

@mclaughlin-thomas mclaughlin-thomas requested a review from a team as a code owner May 7, 2026 06:23
@wiz-code-outsystems
Copy link
Copy Markdown

wiz-code-outsystems Bot commented May 7, 2026

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings -
Software Management Finding Software Management Findings -
Total -

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

Pull Request Developer Guidance

Questions? See the Wiz FAQ.

Please contact the Security Office if you encounter issues with Wiz pull request scanning.

Sign up for free to 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.

1 participant