NousResearch/hermes-agent · warning · Error
File is empty
Error message
File is empty
What it means
parseImportSessions rejects with this when the imported file's text trims to zero length — there is nothing to parse as JSON or JSONL. It fires before JSON.parse is ever attempted, distinguishing an empty file from malformed content (which produces the parse error or 'Expected exported session JSON or JSONL').
Source
Thrown at web/src/lib/session-import.ts:28
Array.isArray((value as { sessions?: unknown }).sessions)
? (value as { sessions: unknown[] }).sessions
: Array.isArray(value)
? value
: [value];
const sessions = candidate.filter(
(item): item is ImportableSession =>
!!item && typeof item === "object" && !Array.isArray(item),
);
if (sessions.length !== candidate.length) {
throw new Error("Expected exported session JSON or JSONL");
}
return sessions;
}
export function parseImportSessions(text: string): ImportableSession[] {
const trimmed = text.trim();
if (!trimmed) throw new Error("File is empty");
try {
return normalizeImportSessions(JSON.parse(trimmed));
} catch (jsonError) {
const lines = trimmed.split(/\r?\n/).filter((line) => line.trim());
if (lines.length <= 1) throw jsonError;
return normalizeImportSessions(lines.map((line) => JSON.parse(line)));
}
}
export function importSummary(result: SessionImportResponse): string {
const parts = [`${result.imported} imported`];
if (result.skipped > 0) parts.push(`${result.skipped} skipped`);
if (result.detached > 0) {
parts.push(`${result.detached} detached from missing parents`);
}
return parts.join("; ");
}View on GitHub (pinned to c896c09c42)
Solutions
- Verify the export file has content (non-zero size) and re-download/re-export if empty.
- Check that the file-picker/drag-drop handler actually receives the File's bytes.
- Show a file-size check in the UI before parsing.
Defensive patterns
Strategy: validation
Validate before calling
if (file.size === 0) {
showError('The selected file is empty — re-export and try again')
return
}
const text = await file.text()
if (!text.trim()) { showError('The selected file is empty'); return } Try / catch
try {
const sessions = parseImportSessions(text)
} catch (err) {
if (String(err) === 'File is empty') { showError('Empty file — pick the real export'); return }
throw err
} Prevention
- Check file.size > 0 at selection time.
- Confirm downloads completed before importing.
- Handle FileReader/drag-drop errors rather than passing empty strings along.
When it happens
Trigger: Selecting a 0-byte file in the session import UI; reading a file that failed to download fully; passing an empty string from a drag-and-drop handler that lost the payload.
Common situations: Interrupted downloads producing empty files; placeholder files created by touch; file-read races where the FileReader got an empty result.
Related errors
- Expected exported session JSON or JSONL
- That project has no folder to move into
- Preview mode — launching is disabled.
- no install root
- ${isPosix ? 'install.sh --manifest' : 'install.ps1 -Manifest
AI-assisted analysis of NousResearch/hermes-agent@c896c09c42 (2026-08-14).
Data as JSON: /api/errors/5eff6a0427c0cdba.
Report an issue: GitHub.