Hmbown/CodeWhale · error · Error
Codewhale runtime event file is empty.
Error message
Codewhale runtime event file is empty.
What it means
fromCodewhaleRuntime is the top-level entry point for turning Codewhale runtime records into a Trace. An empty records array can never yield a trace, so it is rejected up front before any parsing work begins.
Solutions
- Check the source file is non-empty before importing (file size > 0 and at least one JSON line).
- Fix the path/glob so it points at the actual runtime events file.
- Remove or relax the upstream filter that emptied the record list.
- If an empty file is legitimate in your flow, handle it before calling: skip import and create a placeholder/empty trace yourself.
Example fix
// before
const trace = fromCodewhaleRuntime(readJsonl(path));
// after
const records = readJsonl(path);
if (!records.length) return null; // or: throw new Error(`no events in ${path}`)
const trace = fromCodewhaleRuntime(records, path); Defensive patterns
Strategy: try-catch
Validate before calling
const records = readJsonl(path);
if (!records.length) throw new Error(`${path} has no records; check the export`); Try / catch
try {
const trace = fromCodewhaleRuntime(records, filename);
} catch (e) {
if (e.message.includes('event file is empty')) {
// treat as 'no data for this session'; skip or surface a user-facing warning
} else throw e;
} Prevention
- Check file size and line count before importing; 0-byte exports should be caught at the exporter.
- Validate paths/globs resolve to the intended journal file.
- If filtering records upstream, assert the filtered list is non-empty before import.
- Make exporters fail loudly (nonzero exit) when they write zero records.
When it happens
Trigger: Calling fromCodewhaleRuntime([]), or passing the result of reading an empty/zero-byte .jsonl file, or a filtered record list that removed every line.
Common situations: File exists but is empty (0 bytes) or contains only blank lines; a glob or path picked the wrong file; an upstream filter (e.g. by thread_id or event type) matched nothing; a failed export produced an empty file that was still passed on.
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 file contained only stream deltas or…
- Runtime is missing its request identity.
- Runtime import contains multiple threads. Export one thread…
- base URL cannot be empty
- browser URL cannot be empty
AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15).
Data as JSON: /api/errors/716b7e836b58a7a0.
Report an issue: GitHub.
Appendix: source
Thrown at pet/src/core/codewhale.ts:567
source: 'codewhale',
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',
},
};
}
}
export function fromCodewhaleRuntime(records: unknown[], filename = 'Codewhale runtime', maxEvents = 250_000): Trace {
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. */
export function observeRuntimeRequests(trace: Trace, observedThrough: number): Trace {
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)