JuliusBrussee/caveman · error

cave plan fetch failed with HTTP

Error message

cave plan fetch failed with HTTP ${response.status}

What it means

HTTP error from cavePlan in the SDK: the GET to the gateway's /sdk/v1/cave-plan route returned a non-success status. The plan that drives assembly could not be fetched; the status code is embedded in the message.

Solutions

  1. Retry with backoff: transient 5xx/gateway restarts usually clear
  2. Verify the project key and baseURL are correct and the gateway is reachable
  3. Check gateway logs if the status persists (e.g. 401/403 auth, 404 route not deployed)
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at packages/sdk/typescript/src/index.ts:1974 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/7d9fcdbfd1cc4e95. Report an issue: GitHub.

Appendix: source

Thrown at packages/sdk/typescript/src/index.ts:1974

function cloneCanonical(value: unknown): unknown {
  return JSON.parse(canonicalJSON(value)) as unknown;
}

function assemblyText(value: unknown): string {
  return typeof value === "string" ? value : canonicalJSON(value);
}

async function cavePlan(cave: Cave): Promise<CavePlan> {
  // `/sdk/v1/cave-plan` is a gateway-owned project-key route. `controlURL` is
  // reserved for control-api `/api/v1/*` surfaces and must never redirect this
  // call to a route that service does not expose.
  const response = await caveFetch(cave, `${cave.options.baseURL}/sdk/v1/cave-plan`, {
    method: "GET",
    headers: otlpHeaders(cave)
  });
  if (!response.ok) {
    discardResponse(response);
    throw new Error(`cave plan fetch failed with HTTP ${response.status}`);
  }
  // Passed through verbatim: snake_case wire fields, every figure inferred/per-day.
  return (await response.json()) as CavePlan;
}

function strictNonNegativeInt(value: unknown): number | null {
  return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : null;
}

const DEFAULT_HTTP_TIMEOUT_MS = 30_000;

/**
 * Shared bounded transport for every SDK request.
 *
 * The explicit abort race is intentional: callers still settle on deadline when
 * a custom fetch implementation ignores AbortSignal. Native fetch also receives
 * the combined signal, so response-body reads and sockets are cancelled.
 */

View on GitHub (pinned to 3ee70a1026)