{"record":{"id":"b618033824f671b4","repo":"openclaw/openclaw","slug":"crabbox-inspect-returned-invalid-output","errorCode":null,"errorMessage":"Crabbox inspect returned invalid output","messagePattern":"Crabbox inspect returned invalid output","errorType":"exception","errorClass":"WorkerProviderError","httpStatus":null,"severity":"error","filePath":"extensions/crabbox/src/crabbox-worker-provider.ts","lineNumber":270,"sourceCode":"      params.context.provider,\n      \"--network\",\n      \"public\",\n      \"--id\",\n      params.id,\n      \"--json\",\n    ],\n    binary: params.context.binary,\n    runCommand: params.runCommand,\n    timeoutMs: params.timeoutMs ?? CRABBOX_LIFECYCLE_TIMEOUT_MS,\n  });\n  if (result.termination === \"exit\" && result.code === 0) {\n    // A successful but malformed response cannot attest the fixed lease. Command failures and\n    // authoritative absence remain transient so Gateway replay can inspect the live lease later.\n    let inspect: ParsedInspect;\n    try {\n      inspect = parseInspectJson(result.stdout);\n    } catch (error) {\n      throw new WorkerProviderError(\n        error instanceof Error ? error.message : \"Crabbox inspect returned invalid output\",\n      );\n    }\n    if (params.expectedLeaseId && inspect.id !== params.expectedLeaseId) {\n      throw new WorkerProviderError(\"Crabbox inspect returned a different lease id\");\n    }\n    return { status: \"found\", inspect };\n  }\n  if (result.termination === \"exit\" && authoritativeLeaseAbsence(result, params.id)) {\n    return { status: \"unknown\" };\n  }\n  throw crabboxCommandError(\"inspect\", result);\n}\n\nfunction remainingProvisionTimeout(deadline: number, maximum: number): number {\n  const remaining = deadline - Date.now();\n  if (remaining <= 0) {\n    throw new Error(\"Crabbox provision exceeded its provider deadline\");","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/openclaw/openclaw/blob/01804a75319da4b69c9ab98ceaa30477e22b8c0b/extensions/crabbox/src/crabbox-worker-provider.ts#L252-L288","documentation":"Thrown by inspectWithContext() as the fallback message when parseInspectJson rejects with a non-Error value. In practice parseInspectJson always throws Error instances (with specific messages like \"invalid JSON\", \"invalid lease identity or state\", or the field-specific errors 1280-1284), so this exact message is the catch-all for the rare case where the parser throws a non-Error. The actual surfaced message is usually the inner error's message.","triggerScenarios":"inspectWithContext runs `crabbox inspect` successfully (exit 0), then parseInspectJson(result.stdout) throws something that is not an instanceof Error — only then does the fallback \"Crabbox inspect returned invalid output\" fire at crabbox-worker-provider.ts:270-272. Real malformed output surfaces the inner Error's message instead.","commonSituations":"Effectively unreachable because parseInspectJson throws `new Error(...)` exclusively. Could only fire if a future edit to parseInspectJson throws a non-Error (e.g. a string throw), or if a monkeypatch replaces the parser. The user-visible message for genuinely malformed inspect JSON is one of the parser's specific messages (errors 1280-1284 or \"invalid JSON\").","solutions":["Read the actual error message — this fallback is the catch-all; the real cause is in the inner error message that surfaces in the thrown WorkerProviderError.","Re-run `crabbox inspect --provider <p> --id <id> --json` and validate the JSON shape against ParsedInspect.","If you see this exact string with no inner detail, inspect parseInspectJson for a non-Error throw path."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await provider.provision(profile, operationId);\n} catch (error) {\n  if (error instanceof WorkerProviderError && /Crabbox inspect returned/.test(error.message)) {\n    // inspect output failed validation — re-run `crabbox inspect --json` and check the shape\n  }\n  throw error;\n}","preventionTips":["Pin the Crabbox binary version whose inspect JSON matches the ParsedInspect contract.","Never throw non-Error values from parseInspectJson if you patch it — always throw `new Error(...)`.","Treat this fallback message as a signal to inspect parseInspectJson for non-Error throw paths."],"tags":["crabbox","worker-provider","validation","json-parsing","defensive","inspect"],"backgroundTag":null,"analyzedSha":"01804a75319da4b69c9ab98ceaa30477e22b8c0b","analyzedAt":"2026-08-12T04:37:58.197Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}