Review an Outbound HTTP Client for Missing Timeouts, Unbounded Bodies, Unsafe Redirects, and Disabled TLS Checks

You are reviewing a code change that adds or modifies an outbound HTTP client: a wrapper, an SDK integration, or a helper that calls a third-party or internal API. Review only the HTTP behavior, not style.

Check each of the following and report findings in a table with columns: Location, Problem, Concrete failure scenario, Suggested fix, Blocks merge (yes/no).

1. Timeouts. Is there a connect timeout AND a read/total timeout? Library defaults are often unlimited or very long. Does a slow server that drips one byte every few seconds defeat the timeout?
2. Response size. Is the body read fully into memory with no cap? What happens if the server returns a 2 GB body or an endless stream?
3. Redirects. Are redirects followed automatically? Could a redirect send credentials or an Authorization header to a different host? Is there a redirect limit?
4. TLS. Is certificate verification disabled anywhere, even behind a flag or "for local dev"? Is a custom CA bundle handled correctly?
5. Status handling. Are non-2xx responses treated as errors, or does the code parse an error page as if it were data? Are 429 and Retry-After honored?
6. Connection reuse. Is a new client/session created per request (no pooling, socket exhaustion under load), or is one shared client leaked across threads unsafely?
7. Retries. Which requests are retried? Are non-idempotent methods (POST, PATCH) retried without an idempotency key?
8. Logging. Are URLs with tokens in query strings, headers, or bodies logged?

If something looks fine, say so in one line rather than inventing a problem. If you cannot tell from the diff (for example, the client is configured elsewhere), list it under "Needs confirmation" with the exact question to ask.

The diff:
<diff>
{{PASTE DIFF HERE}}
</diff>

---

When to use it: on any pull request that touches code making network calls, especially new integrations. These bugs rarely show in tests because test servers respond fast and small.

How to adapt it: delete items that your shared HTTP layer already enforces (for example, if a platform client sets timeouts centrally), and add your house rules, such as a required User-Agent or tracing header. If the language is Go, ask explicitly about `http.DefaultClient`, which has no timeout.

Example input: a 40-line diff adding `fetch_invoice(id)` that calls `requests.get(url, headers=auth)` with no `timeout` argument and returns `resp.json()`.

What good output looks like: a row flagging the missing timeout ("requests has no default timeout; a hung upstream blocks this worker indefinitely; add timeout=(3, 10); blocks merge: yes"), a row noting that `resp.json()` runs before checking `resp.status_code`, a "fine" line for redirects if auth goes to the same host, and a "Needs confirmation" entry asking whether the session is shared. Weak output lists generic advice like "add error handling" without pointing at a line.

Sign in to upvote this prompt.