earendil-works/pi · error · JsonlDecodeError
schema
schema
Error message
is not a JSON object
What it means
Thrown by the JSONL codec's parseObject when a line parses as valid JSON but is not a plain object (e.g. an array, number, string, or null on its own line). It is a schema-shape guard: JSONL session entries must be objects, so any other top-level JSON value means the file was not written by the session writer.
Solutions
- Ensure every JSONL line decodes to an object; remove or correct lines that hold arrays or scalars.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/agent/src/harness/session/jsonl/codec.ts:40 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24).
Data as JSON: /api/errors/694e9dfc86ac4a4a.
Report an issue: GitHub.
Appendix: source
Thrown at packages/agent/src/harness/session/jsonl/codec.ts:40
"queue_enqueued",
"queue_cancelled",
"write_deferred",
"usage",
]);
const OPERATION_KINDS = new Set(["run", "compaction", "navigation"]);
function isObject(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null && !Array.isArray(value);
}
function parseObject(line: string): Record<string, unknown> {
let value: unknown;
try {
value = JSON.parse(line);
} catch (error) {
throw new JsonlDecodeError("syntax", "is not valid JSON", error instanceof Error ? error : undefined);
}
if (!isObject(value)) throw new JsonlDecodeError("schema", "is not a JSON object");
return value;
}
function requireString(value: unknown, field: string): string {
if (typeof value !== "string") throw new JsonlDecodeError("schema", `has invalid ${field}`);
return value;
}
function requireSequence(value: unknown): number {
if (!Number.isSafeInteger(value) || (value as number) <= 0) {
throw new JsonlDecodeError("schema", "has invalid seq");
}
return value as number;
}
function requireTimestamp(value: unknown): number {
if (!Number.isSafeInteger(value) || (value as number) < 0) {
throw new JsonlDecodeError("schema", "has invalid timestamp");View on GitHub (pinned to 4af9d21d3b)