Hmbown/CodeWhale · error · Error
Codewhale runtime event file is empty.
Error message
Codewhale runtime event file is empty.
What it means
fromCodewhaleRuntime() builds a CodewhaleRuntimeTrace from a parsed array of runtime event records. The library refuses to construct a trace from an empty record list because downstream code (origin-time anchoring, snapshot building) assumes at least one event; an empty input would produce a trace with no origin and no events. It throws this error before any trace object is allocated.
Solutions
- Check that the runtime event file is non-empty (file size > 0 and at least one parsable JSON line) before calling fromCodewhaleRuntime.
- Re-export the runtime events from the Codewhale session and verify the export wrote records.
- If upstream filtering can legitimately drop all rows, handle the empty case in the caller instead of invoking fromCodewhaleRuntime.
Example fix
// before
const trace = fromCodewhaleRuntime(records, file);
// after
if (!records.length) { console.warn(`skipping ${file}: no runtime events`); return; }
const trace = fromCodewhaleRuntime(records, file); Defensive patterns
Strategy: validation
Validate before calling
if (!Array.isArray(records) || records.length === 0) throw new Error(`no runtime events in ${file}`);
const trace = fromCodewhaleRuntime(records, file); Type guard
const hasRecords = (v: unknown): v is object[] => Array.isArray(v) && v.length > 0;
Try / catch
let trace;
try { trace = fromCodewhaleRuntime(records, file); }
catch (e) { if (e.message.includes('event file is empty')) return null; throw e; } Prevention
- Check file size and parseable line count before import.
- Log record counts at every pipeline stage to spot filters dropping everything.
- Reject empty exports at export time in the producer.
When it happens
Trigger: Calling fromCodewhaleRuntime([], ...) — e.g. a runtime event file that parses to zero JSON lines, a file containing only whitespace or comments, or a filtered/decoder step that dropped every record before the call.
Common situations: Exporting a Codewhale session before any runtime events were recorded, truncating a .jsonl export with a shell command that leaves only a trailing newline, or piping an empty stream into the importer.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- Codewhale runtime event file is empty.
- Codewhale runtime event file is empty.
- Codewhale runtime file contained only stream deltas or…
- Codewhale session contains no journal entries or messages.
- Codewhale session produced no inspectable events.
AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15).
Data as JSON: /api/errors/8d4042ae43aadf2c.
Report an issue: GitHub.
Appendix: source
Thrown at pet/ios/Resources/pet-native.js:2512
privacy: 'redact',
warnings: [...new Set(warnings)],
metadata: {
sourceFormat: 'codewhale.runtime-events/v2',
timeBasis: 'wall-clock',
sourceFilename: filename,
threadId,
model,
skippedDeltas,
recordCount: this.recordCount,
timeUnit: 'ms',
},
};
}
}
exports.CodewhaleRuntimeTrace = CodewhaleRuntimeTrace;
function fromCodewhaleRuntime(records, filename = 'Codewhale runtime', maxEvents = 250_000) {
if (!records.length)
throw new Error('Codewhale runtime event file is empty.');
const trace = new CodewhaleRuntimeTrace(filename, maxEvents);
trace.append(records);
return trace.snapshot();
}
/** The journal owns request state until a matching terminal receipt. A live
* driver may confirm that state only while its cursor-checked stream is healthy.
* Ordinary open tool spans remain unknown-duration; no execution is inferred. */
function observeRuntimeRequests(trace, observedThrough) {
const origin = Date.parse(trace.originTime ?? '');
if (trace.metadata.sourceFormat !== 'codewhale.runtime-events/v2' || !Number.isFinite(origin)
|| !Number.isFinite(observedThrough))
throw new Error('Invalid Runtime observation horizon.');
const at = observedThrough - origin;
const events = trace.events.map(e => e.openEnded && e.attributes['whalesong.waiting'] === true && at >= e.startTime
? { ...e, endTime: at, openEnded: false } : e);
return { ...trace, events, duration: Math.max(trace.duration, at) };
}
View on GitHub (pinned to 433685b202)