{"record":{"id":"e61947c35103617f","repo":"openclaw/openclaw","slug":"crabbox-inspect-returned-an-invalid-field","errorCode":null,"errorMessage":"Crabbox inspect returned an invalid ${field}","messagePattern":"Crabbox inspect returned an invalid (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extensions/crabbox/src/crabbox-worker-inspect.ts","lineNumber":107,"sourceCode":"    state,\n    tailscaleEnabled,\n    sshFallbackPorts,\n    ...(awsInstanceProfileAttached !== undefined ? { awsInstanceProfileAttached } : {}),\n    ...(host ? { host } : {}),\n    ...(sshUser ? { sshUser } : {}),\n    ...(sshHostKey ? { sshHostKey } : {}),\n    ...(sshKey ? { sshKey } : {}),\n    ...(sshPort ? { sshPort } : {}),\n    ...(typeof value.ready === \"boolean\" ? { ready: value.ready } : {}),\n  };\n}\n\nfunction inspectString(value: unknown, field: string): string | undefined {\n  if (value === undefined) {\n    return undefined;\n  }\n  if (typeof value !== \"string\") {\n    throw new Error(`Crabbox inspect returned an invalid ${field}`);\n  }\n  return nonEmptyString(value);\n}\n\nfunction inspectPort(value: unknown): number | undefined {\n  if (value === undefined || value === \"\") {\n    return undefined;\n  }\n  return inspectRequiredPort(value, \"sshPort\");\n}\n\nfunction inspectFallbackPorts(value: unknown, primaryPort: number | undefined): number[] {\n  if (value === undefined) {\n    return [];\n  }\n  if (!Array.isArray(value)) {\n    throw new Error(\"Crabbox inspect returned invalid sshFallbackPorts\");\n  }","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/openclaw/openclaw/blob/01804a75319da4b69c9ab98ceaa30477e22b8c0b/extensions/crabbox/src/crabbox-worker-inspect.ts#L89-L125","documentation":"Thrown by inspectString() when a Crabbox inspect JSON field that must be a string (sshHost, host, sshUser, sshHostKey, or sshKey) is present but not of type string (e.g. a number, object, array, or null). The Crabbox provider treats the binary's inspect output as untrusted and validates every field; a non-string where a string endpoint field is expected means the lease contract is broken and cannot be used. The ${field} placeholder is interpolated with the offending field name.","triggerScenarios":"Calling WorkerProvider.provision/inspect whose Crabbox binary emits JSON where one of sshHost, host, sshUser, sshHostKey, or sshKey is a non-string scalar (e.g. {\"sshUser\": 1001} or {\"sshHostKey\": null}). Triggered inside parseInspectJson at crabbox-worker-inspect.ts:79-84.","commonSituations":"Crabbox binary version mismatch where a newer/older CLI emits numeric UIDs or null for absent fields instead of strings; a buggy custom Crabbox provider plugin returning wrong types; corrupted lease metadata in the coordinator backend surfacing as JSON with unexpected scalar types.","solutions":["Re-run `crabbox inspect --provider <p> --id <id> --json` manually and inspect the raw JSON for the named field's value and type.","Upgrade or downgrade the Crabbox binary to the version whose inspect contract matches this provider (check CHANGELOG for sshUser/sshHostKey type changes).","If using a custom provider plugin in Crabbox, ensure its inspect implementation emits strings (or omits the field) for sshHost, host, sshUser, sshHostKey, sshKey.","Destroy the malformed lease with `crabbox stop --provider <p> --id <id>` and provision a fresh one."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isInspectStringField(value: unknown): value is string {\n  return typeof value === \"string\";\n}","tryCatchPattern":"try {\n  await provider.provision(profile, operationId);\n} catch (error) {\n  if (error instanceof Error && /Crabbox inspect returned an invalid (sshHost|host|sshUser|sshHostKey|sshKey)/.test(error.message)) {\n    // malformed lease metadata — destroy and re-provision with a known-good Crabbox binary\n  }\n  throw error;\n}","preventionTips":["Pin the Crabbox binary version whose inspect JSON contract matches this provider.","For custom Crabbox provider plugins, emit strings (or omit the field) for sshHost, host, sshUser, sshHostKey, sshKey.","Treat inspect output as untrusted: never bypass parseInspectJson validation in tests or wrappers."],"tags":["crabbox","worker-provider","validation","json-parsing","ssh"],"backgroundTag":null,"analyzedSha":"01804a75319da4b69c9ab98ceaa30477e22b8c0b","analyzedAt":"2026-08-12T04:37:58.197Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}