{"record":{"id":"f661529976ea7193","repo":"garrytan/gstack","slug":"sidecar-circuit-broken","errorCode":null,"errorMessage":"sidecar-circuit-broken","messagePattern":"sidecar-circuit-broken","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"browse/src/security-sidecar-client.ts","lineNumber":186,"sourceCode":"  reason?: string;\n}\n\nexport function isSidecarAvailable(): SidecarAvailability {\n  const s = getState();\n  if (s.brokenCircuit) return { available: false, reason: \"circuit-broken\" };\n  if (s.child) return { available: true };\n  // Probe via findSecuritySidecar without spawning. If the resolver returns\n  // null (no node on PATH, no entry on disk), we're permanently unavailable\n  // until a setup re-run.\n  const location = findSecuritySidecar();\n  if (!location) return { available: false, reason: \"no-node-or-entry\" };\n  return { available: true };\n}\n\nexport async function scanWithSidecar(text: string, opts?: { timeoutMs?: number }): Promise<{ verdict: unknown }> {\n  const s = getState();\n  if (s.brokenCircuit) {\n    throw new Error(\"sidecar-circuit-broken\");\n  }\n  if (Buffer.byteLength(text, \"utf-8\") > REQUEST_CAP_BYTES) {\n    throw new Error(\"payload-too-large\");\n  }\n  if (!s.child) {\n    if (!spawnSidecar()) {\n      throw new Error(\"sidecar-spawn-failed\");\n    }\n  }\n  const id = String(s.nextId++);\n  const timeoutMs = opts?.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n\n  return new Promise((resolve, reject) => {\n    const timer = setTimeout(() => {\n      s.pending.delete(id);\n      recordFailure();\n      reject(new Error(\"sidecar-timeout\"));\n    }, timeoutMs);","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/security-sidecar-client.ts#L168-L204","documentation":"Error \"sidecar-circuit-broken\" thrown in garrytan/gstack.","triggerScenarios":"Thrown at browse/src/security-sidecar-client.ts:186 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"94993f74012782fd94416dd44b8314f6363a13a4","analyzedAt":"2026-08-12T04:06:23.140Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}