{"record":{"id":"15dfa1c128efd5e1","repo":"can1357/oh-my-pi","slug":"response-ok-must-be-a-boolean","errorCode":null,"errorMessage":"response.ok must be a boolean","messagePattern":"response\\.ok must be a boolean","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/launch/protocol.ts","lineNumber":324,"sourceCode":"\t\tcompletionReplays:\n\t\t\tsource.completionReplays === undefined\n\t\t\t\t? undefined\n\t\t\t\t: stringArray(source.completionReplays, \"request.completionReplays\"),\n\t\tcompletionSubscriptionId:\n\t\t\tsource.completionSubscriptionId === undefined\n\t\t\t\t? undefined\n\t\t\t\t: stringValue(source.completionSubscriptionId, \"request.completionSubscriptionId\"),\n\t\toperation: parseDaemonOperation(source.operation),\n\t};\n}\n\n/** Decode a socket response envelope before resolving a pending call. */\nexport function parseDaemonWireResponse(value: unknown): DaemonWireResponse {\n\tconst source = record(value, \"daemon response\");\n\tconst id = stringValue(source.id, \"response.id\");\n\tif (source.ok === true) return { id, ok: true, result: source.result };\n\tif (source.ok === false) return { id, ok: false, error: stringValue(source.error, \"response.error\") };\n\tthrow new Error(\"response.ok must be a boolean\");\n}\n\n/** Decode one broker response or unsolicited completion notification. */\nexport function parseDaemonWireMessage(value: unknown): DaemonWireMessage {\n\tconst source = record(value, \"daemon message\");\n\tif (source.event === \"daemon-completed\") {\n\t\treturn {\n\t\t\tevent: \"daemon-completed\",\n\t\t\tcompletionId: stringValue(source.completionId, \"completion.id\"),\n\t\t\towner: stringValue(source.owner, \"completion.owner\"),\n\t\t\tdaemon: parseDaemonSnapshot(source.daemon),\n\t\t};\n\t}\n\treturn parseDaemonWireResponse(value);\n}\n\nfunction parseDaemonOperation(value: unknown): DaemonOperation {\n\tconst source = record(value, \"daemon operation\");","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/launch/protocol.ts#L306-L342","documentation":"parseDaemonWireResponse validates the wire envelope of a daemon socket response. The broker protocol requires the `ok` field to be exactly true or false so the pending call can be resolved as a result or an error; anything else means the payload is malformed or not a daemon response at all.","triggerScenarios":"Calling parseDaemonWireResponse/parseDaemonWireMessage with a parsed JSON object whose `ok` field is missing, undefined, null, a string like \"true\", or a number.","commonSituations":"Protocol version mismatch between client and daemon, a hand-rolled mock server emitting wrong-shaped envelopes, corruption or truncation of the socket stream producing partial/foreign JSON, or pointing the client at the wrong socket that serves a different protocol.","solutions":["Verify the daemon binary version matches the client (upgrade or restart the daemon with `omp daemon restart` equivalent).","Log the raw payload before parsing to inspect the actual `ok` value and envelope shape.","Check that the socket path belongs to the omp daemon and not another process.","Update to matching client/daemon versions if protocol fields changed."],"exampleFix":"// before\nconst msg = JSON.parse(raw);\nconst resp = parseDaemonWireResponse(msg); // throws if msg.ok is undefined\n// after\nconst msg = JSON.parse(raw);\nif (typeof msg?.ok !== \"boolean\") throw new Error(`unexpected daemon envelope: ${raw.slice(0, 200)}`);\nconst resp = parseDaemonWireResponse(msg);","handlingStrategy":"validation","validationCode":"function isDaemonEnvelope(v: unknown): v is { ok: boolean } {\n  return typeof v === \"object\" && v !== null && typeof (v as any).ok === \"boolean\";\n}","typeGuard":"const isDaemonResponse = (v: unknown): v is Record<string, unknown> & { ok: boolean } =>\n  typeof v === \"object\" && v !== null && \"ok\" in v && typeof (v as { ok: unknown }).ok === \"boolean\";","tryCatchPattern":"try {\n  const resp = parseDaemonWireResponse(JSON.parse(raw));\n} catch (err) {\n  if (err.message.includes(\"response.ok must be a boolean\")) {\n    logger.warn(\"malformed daemon envelope\", { raw: raw.slice(0, 200) });\n    // drop or reconnect\n  } else throw err;\n}","preventionTips":["Pin client and daemon to the same version","Validate socket payloads at the boundary before parsing","Log raw envelopes when the protocol errors","Never point the client at a foreign socket path"],"tags":["protocol","validation","ipc","daemon"],"backgroundTag":"schema-validation-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}