ruvnet/RuView · error · TypeError
prompt must be a non-empty string
Error message
prompt must be a non-empty string
What it means
runCodex (harness/ruview/src/hosts/codex.js) is the host adapter that spawns `codex exec -` with the prompt on stdin. It requires a string prompt with non-whitespace content; empty, null, or non-string prompts throw before the repo-trust check or process spawn.
Source
Thrown at harness/ruview/src/hosts/codex.js:12
// SPDX-License-Identifier: MIT
import { runProcess } from '../process-runner.js';
import { assertTrustedRuViewRepo } from '../repo-trust.js';
export function buildCodexArgs(root, { write = false } = {}) {
return ['exec', '-', '-C', root, '--sandbox', write ? 'workspace-write' : 'read-only',
'--ephemeral', '--json', '--strict-config', '--ignore-user-config', '--ignore-rules'];
}
export async function runCodex({
prompt, repoRoot, trustedRoot = repoRoot, allowWrite = false, confirm = false,
command = 'codex', commandArgs = [], ...runOptions
}) {
if (typeof prompt !== 'string' || !prompt.trim()) throw new TypeError('prompt must be a non-empty string');
const root = assertTrustedRuViewRepo(repoRoot, { trustedRoot });
const write = allowWrite === true && confirm === true;
return runProcess(command, [...commandArgs, ...buildCodexArgs(root, { write })], { ...runOptions, cwd: root, input: prompt });
}
export default Object.freeze({ name: 'codex', run: runCodex, buildArgs: buildCodexArgs });
View on GitHub (pinned to 4685618388)
Solutions
- Validate the prompt before calling: if (typeof prompt !== 'string' || !prompt.trim()) fail early with context.
- Read the prompt file first and assert non-empty content.
- Pass a concrete task string: runCodex({ prompt: 'Map startup restore and cite files', repoRoot }).
Example fix
// before
runCodex({ prompt: readFileSync(promptFile, 'utf8'), repoRoot }) // file was empty
// after
const prompt = readFileSync(promptFile, 'utf8').trim();
if (!prompt) throw new Error(`prompt file is empty: ${promptFile}`);
runCodex({ prompt, repoRoot }); Defensive patterns
Strategy: validation
Validate before calling
const prompt = typeof rawPrompt === 'string' ? rawPrompt.trim() : '';
if (!prompt) throw new Error('codex host requires a non-empty prompt');
runCodex({ prompt, repoRoot }); Type guard
function isNonEmptyPrompt(v) {
return typeof v === 'string' && v.trim().length > 0;
} Try / catch
try {
await runCodex({ prompt, repoRoot });
} catch (e) {
if (e instanceof TypeError && e.message === 'prompt must be a non-empty string') {
throw new Error('codex delegation aborted: prompt was empty');
}
throw e;
} Prevention
- Validate prompt files/stdin for non-whitespace content before delegation.
- Prompt goes to `codex exec -` via stdin — keep it a plain string.
- Fail with your own contextual error so callers know the builder, not the host, is at fault.
When it happens
Trigger: runCodex({}) (prompt undefined), runCodex({ prompt: '' }), runCodex({ prompt: '\n ' }), or reading the prompt from an empty file/stdin before passing it through.
Common situations: Empty stdin when the agent-run command is scripted (`agent run --prompt-file empty.txt`); template builders returning blank strings; prompt sent as an object or buffer instead of a string.
Related errors
- prompt must be a non-empty string
- Unsupported host: ${name}
- guidance input must be an object
- guidance options must be an object
- guidance topic must be a string
AI-assisted analysis of ruvnet/RuView@4685618388 (2026-08-16).
Data as JSON: /api/errors/da7acaf24af2313f.
Report an issue: GitHub.