fix: keep loopback and LAN traffic off an ambient proxy

Pre-existing on main, not introduced by the driver work, but it makes a local
RAG backend unusable so it belongs with this change.

build_client only called set_proxy when a client had configured one of its own.
With nothing configured, reqwest's own detection applied, which sends every
request through a *_PROXY variable including ones bound for 127.0.0.1 or a LAN
address. A proxy cannot usefully forward those, and anything that intercepts
proxied traffic answers on behalf of a service that is running perfectly well,
so the error names the proxy rather than the store and reads as a Coyote fault.

Concretely, an installed Socket Firewall exports HTTP_PROXY to the processes it
wraps and rejects hosts outside its allow list. That turned a healthy Ollama on
the LAN into 'error decoding response body: expected value at line 2 column 1' —
its HTML refusal page parsed as JSON — and a loopback Qdrant into an HTTP 405.

Proxy handling is now always applied and always exempts loopback and private
ranges, with NO_PROXY merged in since replacing reqwest's detection also
replaces its handling of that variable. HTTP_PROXY and HTTPS_PROXY are kept
separate because they are allowed to differ. An explicitly configured proxy
still wins, and '-' still means none.

This also supersedes the unconditional no_proxy() added to the Qdrant client in
af9622d: that made it the only client to ignore a proxy outright, on a
justification I got wrong. It now shares this path, so a remote store behind a
real proxy keeps working.
This commit is contained in:
2026-08-12 10:33:03 -06:00
parent 4dd6e794b2
commit 54685be9a2
3 changed files with 115 additions and 12 deletions
+2 -3
View File
@@ -1,5 +1,6 @@
use crate::rag::provider::RagProvider;
use crate::rag::{DocumentId, RagData};
use crate::utils::apply_proxy;
use anyhow::{Context, Result, bail};
use async_trait::async_trait;
@@ -191,9 +192,7 @@ impl QdrantProvider {
value.set_sensitive(true);
headers.insert("api-key", value);
}
Client::builder()
.default_headers(headers)
.no_proxy()
apply_proxy(Client::builder().default_headers(headers), None)?
.build()
.context("Failed to build reqwest client")
}