Yeachan-Heo/oh-my-codex · error · Error
fileName must be a non-empty string
Error message
fileName must be a non-empty string
What it means
Thrown when fileName trims to an empty string. An empty filename would resolve to the state directory itself rather than a file, so it is rejected.
Source
Thrown at src/mcp/state-paths.ts:160
throw new Error('mode must not contain path separators');
}
if (!STATE_MODE_SEGMENT_PATTERN.test(normalized)) {
throw new Error('mode must match ^[A-Za-z0-9_-]{1,64}$');
}
return normalized;
}
export function getStateFilename(mode: string): string {
return `${validateStateModeSegment(mode)}${STATE_FILE_SUFFIX}`;
}
export function validateStateFileName(fileName: unknown): string {
if (typeof fileName !== 'string') {
throw new Error('fileName must be a string');
}
const normalized = fileName.trim();
if (!normalized) {
throw new Error('fileName must be a non-empty string');
}
if (normalized.includes('..')) {
throw new Error('fileName must not contain ".."');
}
if (normalized.includes('/') || normalized.includes('\\')) {
throw new Error('fileName must not contain path separators');
}
if (!STATE_FILE_NAME_PATTERN.test(normalized)) {
throw new Error('fileName must match ^[A-Za-z0-9._-]{1,128}$');
}
return normalized;
}
function convertWindowsToWslPath(raw: string): string {
const m = /^([a-zA-Z]):[\\/](.*)$/.exec(raw);
if (!m) return raw;
const drive = m[1].toLowerCase();
const rest = String(m[2] || '').replace(/\\/g, '/');View on GitHub (pinned to 3ad79a8a6f)
Solutions
- Omit the fileName when empty rather than passing ""
- Default to a concrete name like "state.json"
- Validate with .trim() at config load
Example fix
// before
getStateFilePath(" ");
// after
getStateFilePath("state.json"); Defensive patterns
Strategy: validation
Validate before calling
fileName = fileName?.trim() || 'state.json';
Type guard
function isNonEmptyFileName(v: string): boolean { return v.trim().length > 0; } Prevention
- Use undefined for absent, never empty string
- Default blank inputs to a concrete filename
When it happens
Trigger: fileName: "", fileName: " ", or a whitespace-only value from trimmed form input.
Common situations: Optional fileName field defaulted to "" instead of undefined; template strings producing empty output; copy-paste of blank cells from spreadsheets.
Related errors
- mode must be a non-empty string
- ${name} must be non-empty
- worktreeName must be a relative safe worktree name
- mode must be a string
- mode must not contain ".."
AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27).
Data as JSON: /api/errors/932c5a6a33ab617e.
Report an issue: GitHub.