can1357/oh-my-pi · error

response.ok must be a boolean

Error message

response.ok must be a boolean

What it means

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.

Source

Thrown at packages/coding-agent/src/launch/protocol.ts:324

		completionReplays:
			source.completionReplays === undefined
				? undefined
				: stringArray(source.completionReplays, "request.completionReplays"),
		completionSubscriptionId:
			source.completionSubscriptionId === undefined
				? undefined
				: stringValue(source.completionSubscriptionId, "request.completionSubscriptionId"),
		operation: parseDaemonOperation(source.operation),
	};
}

/** Decode a socket response envelope before resolving a pending call. */
export function parseDaemonWireResponse(value: unknown): DaemonWireResponse {
	const source = record(value, "daemon response");
	const id = stringValue(source.id, "response.id");
	if (source.ok === true) return { id, ok: true, result: source.result };
	if (source.ok === false) return { id, ok: false, error: stringValue(source.error, "response.error") };
	throw new Error("response.ok must be a boolean");
}

/** Decode one broker response or unsolicited completion notification. */
export function parseDaemonWireMessage(value: unknown): DaemonWireMessage {
	const source = record(value, "daemon message");
	if (source.event === "daemon-completed") {
		return {
			event: "daemon-completed",
			completionId: stringValue(source.completionId, "completion.id"),
			owner: stringValue(source.owner, "completion.owner"),
			daemon: parseDaemonSnapshot(source.daemon),
		};
	}
	return parseDaemonWireResponse(value);
}

function parseDaemonOperation(value: unknown): DaemonOperation {
	const source = record(value, "daemon operation");

View on GitHub (pinned to 9690622007)

Solutions

  1. Verify the daemon binary version matches the client (upgrade or restart the daemon with `omp daemon restart` equivalent).
  2. Log the raw payload before parsing to inspect the actual `ok` value and envelope shape.
  3. Check that the socket path belongs to the omp daemon and not another process.
  4. Update to matching client/daemon versions if protocol fields changed.

Example fix

// before
const msg = JSON.parse(raw);
const resp = parseDaemonWireResponse(msg); // throws if msg.ok is undefined
// after
const msg = JSON.parse(raw);
if (typeof msg?.ok !== "boolean") throw new Error(`unexpected daemon envelope: ${raw.slice(0, 200)}`);
const resp = parseDaemonWireResponse(msg);
Defensive patterns

Strategy: validation

Validate before calling

function isDaemonEnvelope(v: unknown): v is { ok: boolean } {
  return typeof v === "object" && v !== null && typeof (v as any).ok === "boolean";
}

Type guard

const isDaemonResponse = (v: unknown): v is Record<string, unknown> & { ok: boolean } =>
  typeof v === "object" && v !== null && "ok" in v && typeof (v as { ok: unknown }).ok === "boolean";

Try / catch

try {
  const resp = parseDaemonWireResponse(JSON.parse(raw));
} catch (err) {
  if (err.message.includes("response.ok must be a boolean")) {
    logger.warn("malformed daemon envelope", { raw: raw.slice(0, 200) });
    // drop or reconnect
  } else throw err;
}

Prevention

When it happens

Trigger: Calling parseDaemonWireResponse/parseDaemonWireMessage with a parsed JSON object whose `ok` field is missing, undefined, null, a string like "true", or a number.

Common situations: 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.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/15dfa1c128efd5e1. Report an issue: GitHub.