JuliusBrussee/caveman · error
cave_gateway_identity_unverified
cave_gateway_identity_unverified
Error message
cave_gateway_identity_unverified: non-loopback gateway ${gatewayURL} requires https What it means
For non-loopback gateway hosts, the runtime requires https because it forwards the provider credential plus all x-cave-* headers to that host, and the peer must prove Caveman identity. Plain http cannot authenticate the peer at all, so resolveCaveRoute fails closed with this error rather than leaking credentials to an unauthenticated host.
Solutions
- Serve the gateway over https (TLS cert on the gateway, or put it behind an https reverse proxy)
- Update gatewayURL to https:// in the runtime/agent config
- If the gateway is truly local, use a loopback host (127.0.0.1 or localhost), which is exempt from the https requirement
Example fix
// before const gatewayURL = 'http://gateway.internal:7788'; // after const gatewayURL = 'https://gateway.internal:7788';
Defensive patterns
Strategy: validation
Validate before calling
const u = new URL(gatewayURL);
const isLoopback = ['127.0.0.1','localhost','::1'].includes(u.hostname);
if (!isLoopback && u.protocol !== 'https:') throw new Error('non-loopback gateway must be https'); Type guard
function isSecureGateway(url: string): boolean {
const u = new URL(url);
return u.protocol === 'https:' || ['127.0.0.1','localhost','::1'].includes(u.hostname);
} Prevention
- Default all non-loopback gateway URLs to https in config templates
- Terminate TLS at the gateway or a reverse proxy
- Restrict non-https gateways to loopback hosts in dev only
When it happens
Trigger: Configuring gatewayURL with an http:// scheme whose host is not loopback (not 127.0.0.1/localhost/::1), so the credential-forwarding path refuses to trust it.
Common situations: Pointing the gateway at a LAN or remote machine with http://; copy-pasting an internal http URL into CAVEMAN gateway config; TLS termination misconfigured so only http is served.
Understand the failure class
Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.
Related errors
- objectstore: production requires TLS
- postgres: or is required in production
- cave_gateway_required_for_locked_plan
- objectstore: production endpoint must be an HTTPS origin…
- postgres: CA certificate configured while TLS is disabled
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/036c640dad80319c.
Report an issue: GitHub.
Appendix: source
Thrown at packages/agent/src/runtime.ts:5221
});
return probe;
}
export async function ensureCaveRuntime(
gatewayURL: string,
fetchImpl: typeof globalThis.fetch,
): Promise<GatewayProviderBilling> {
const url = new URL(gatewayURL);
const loopback = isLoopbackHostname(url.hostname);
if (!loopback) {
// A non-loopback gateway is never taken on faith: routing there sends the
// provider credential plus every x-cave-* header to that host, so it must
// prove Caveman identity before it gets any traffic. Plain http cannot
// authenticate the peer at all, and an https host that fails the
// /health/ready identity handshake is equally unverified — both fail
// closed here so resolveCaveRoute degrades to observe-only passthrough.
if (url.protocol !== "https:") {
throw new Error(
`cave_gateway_identity_unverified: non-loopback gateway ${gatewayURL} requires https`,
);
}
const identity = await gatewayIdentity(gatewayURL, fetchImpl);
if (identity !== undefined) return identity.providerBilling;
throw new Error(
`cave_gateway_identity_unverified: ${gatewayURL}/health/ready did not identify as caveman-proxy`,
);
}
const readyBilling = await runtimeReady(gatewayURL, fetchImpl);
if (readyBilling !== undefined) return readyBilling;
const command = process.env.CAVEMAN_CLI_BIN ?? "caveman";
let startupFailure: Error | undefined;
let invocation;
try {
invocation = portableInvocation(command, ["start"], { env: buildRuntimeControlEnv() });
} catch (error) {View on GitHub (pinned to 3ee70a1026)