{"record":{"id":"3aa36b9758f5dbb3","repo":"paperclipai/paperclip","slug":"sandbox-namespace-name-failed-mapped-reas","errorCode":null,"errorMessage":"Sandbox ${namespace}/${name} failed: ${mapped.reason ?? (failedCondition?.reason as string) ?? \"unknown reason\"} — ${mapped.message ?? (failedCondition?.message as string) ?? \"\"}","messagePattern":"Sandbox (.+?)/(.+?) failed: (.+?) — (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/plugins/sandbox-providers/kubernetes/src/sandbox-cr-orchestrator.ts","lineNumber":281,"sourceCode":"      namespace,\n      plural: SANDBOX_PLURAL,\n      name,\n    }) as Record<string, unknown>;\n\n    const status = (cr.status as Record<string, unknown>) ?? {};\n    // agent-sandbox v1alpha1 uses status.conditions[type=Ready,status=True],\n    // not status.phase. Fall back to phase for forward-compat.\n    const conditions = Array.isArray(status.conditions) ? status.conditions as Array<Record<string, unknown>> : [];\n    const readyCondition = conditions.find((c) => c.type === \"Ready\");\n    const failedCondition = conditions.find((c) => c.type === \"Failed\" || (c.type === \"Ready\" && c.status === \"False\" && typeof c.reason === \"string\" && /failed/i.test(c.reason)));\n    const phase = (status.phase as string) ?? \"\";\n\n    if (readyCondition?.status === \"True\" || phase === \"Ready\") {\n      return mapSandboxPhase(cr);\n    }\n    if (failedCondition?.status === \"True\" || phase === \"Failed\") {\n      const mapped = mapSandboxPhase(cr);\n      throw new Error(\n        `Sandbox ${namespace}/${name} failed: ${mapped.reason ?? (failedCondition?.reason as string) ?? \"unknown reason\"} — ${mapped.message ?? (failedCondition?.message as string) ?? \"\"}`,\n      );\n    }\n    if (phase === \"Terminating\") {\n      // A Sandbox being torn down will never transition to Ready. Polling\n      // until the deadline would burn the full timeoutMs (potentially\n      // 30+ minutes) before throwing a generic timeout. Fail fast instead\n      // so the caller can surface a clear \"the lease is being released\"\n      // error and decide whether to retry against a fresh Sandbox.\n      throw new Error(\n        `Sandbox ${namespace}/${name} is Terminating — cannot wait for Ready`,\n      );\n    }\n    // Pending — keep polling\n    await sleep(pollMs);\n  }\n\n  throw new SandboxCrTimeoutError(namespace, name, opts.timeoutMs);","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/packages/plugins/sandbox-providers/kubernetes/src/sandbox-cr-orchestrator.ts#L263-L299","documentation":"Error \"Sandbox ${namespace}/${name} failed: ${mapped.reason ?? (failedCondition?.reason as string) ?? \"unknown reason\"} — ${mapped.message ?? (failedCondition?.message as string) ?? \"\"}\" thrown in paperclipai/paperclip.","triggerScenarios":"Thrown at packages/plugins/sandbox-providers/kubernetes/src/sandbox-cr-orchestrator.ts:281 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the reported reason/message and the sandbox CR events in the namespace; fix the failing condition."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"120ae5428fa29bee300bcf806491cd4d965fbb7c","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}