Skip to content

fix: keep the default HTTP transport compatible with OPA - #42

Merged
ravi-pplx merged 3 commits into
pplx/mainfrom
fix/opa-http-send-transport
Nov 16, 2026
Merged

ravi-pplx merged 3 commits into
pplx/mainfrom
fix/opa-http-send-transport

Conversation

@ravi-pplx

Copy link
Copy Markdown

OPA's TLS-enabled http.send panics when Cachew replaces http.DefaultTransport with its backoff wrapper.

Ports block/cachew#449, keeping the default transport intact and wiring upstream clients explicitly. Adapts the patch to retain zero-backoff behavior and shared transport coverage for GitHub object batches and Socket policy requests.

Created with Perplexity

dgilman-perplexity and others added 2 commits November 13, 2026 23:08
configureProcess replaced the global http.DefaultTransport with the
BackoffTransport/OriginTransport wrapper so every strategy shared 429
cooldowns and origin metrics. OPA's http.send asserts
http.DefaultTransport.(*http.Transport) whenever a policy sets a TLS
option such as tls_ca_cert_file, so every policy evaluation that reached
http.send panicked with "interface conversion: http.RoundTripper is
*httputil.BackoffTransport, not *http.Transport" and net/http dropped
the client connection.

Install the wrapper through httputil.SetUpstreamTransport instead, and
give every client that relied on the default transport or
http.DefaultClient the shared transport explicitly via
httputil.UpstreamTransport / httputil.UpstreamClient. Until a transport
is installed the accessor forwards to the live http.DefaultTransport, so
tests that swap the global to intercept upstream traffic keep working.

The regression test runs a real http.send with tls_ca_cert_file after
configureProcess in a child process; it fails with the panic above on
the previous code.

Co-authored-by: Perplexity <noreply@perplexity.ai>
Signed-off-by: dgilman-perplexity <293900578+dgilman-perplexity@users.noreply.github.com>
(cherry picked from commit c5d94a3)
Keep GitHub object batches and Socket policy requests on the shared
upstream transport after the global default is restored. Exercise the
real client wiring so cooldown and instrumentation coverage cannot
silently disappear.

Co-authored-by: Perplexity <noreply@perplexity.ai>
@ravi-pplx
ravi-pplx marked this pull request as ready for review November 14, 2026 01:49
Prune the unreachable commit so the mirror cannot serve it locally, and
use an independent client so the request cannot bypass the handler.
Verify the forwarded method, path and body, the upstream response, and
exactly one fallback request.

Co-authored-by: Perplexity <noreply@perplexity.ai>
@ravi-pplx
ravi-pplx merged commit dac8ebb into pplx/main Nov 16, 2026
4 checks passed
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.

2 participants