ruvnet/RuView · error · TypeError
prompt must be a non-empty string
Error message
prompt must be a non-empty string
What it means
runClaudeCode (harness/ruview/src/hosts/claude-code.js) is the host adapter that spawns `claude -p` for delegated analysis. It destructures { prompt, ... } and immediately requires a string with non-whitespace content; empty, null, numeric, or undefined prompts throw before the repo-trust check or process spawn.
Source
Thrown at harness/ruview/src/hosts/claude-code.js:12
// SPDX-License-Identifier: MIT
import { runProcess } from '../process-runner.js';
import { assertTrustedRuViewRepo } from '../repo-trust.js';
export function buildClaudeCodeArgs({ write = false } = {}) {
return ['-p', '--safe-mode', '--output-format', 'json', '--no-session-persistence', '--permission-mode', write ? 'acceptEdits' : 'plan',
'--allowedTools', write ? 'Read,Grep,Glob,Edit,Write' : 'Read,Grep,Glob'];
}
export async function runClaudeCode({
prompt, repoRoot, trustedRoot = repoRoot, allowWrite = false, confirm = false,
command = 'claude', 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, ...buildClaudeCodeArgs({ write })], { ...runOptions, cwd: root, input: prompt });
}
export default Object.freeze({ name: 'claude-code', run: runClaudeCode, buildArgs: buildClaudeCodeArgs });
View on GitHub (pinned to 4685618388)
Solutions
- Build and check the prompt first: const prompt = buildPrompt(args).trim(); if (!prompt) fail with your own clearer error.
- Pass a concrete string: runClaudeCode({ prompt: 'Find the nearest tests and cite files', repoRoot }).
- Log the prompt when delegation fails so empty-template bugs are visible.
Example fix
// before
runClaudeCode({ prompt: buildPrompt(ctx), repoRoot }) // buildPrompt returned ''
// after
const prompt = buildPrompt(ctx).trim();
if (!prompt) throw new Error('empty prompt: provide a task for the claude-code host');
runClaudeCode({ prompt, repoRoot }); Defensive patterns
Strategy: validation
Validate before calling
const prompt = typeof rawPrompt === 'string' ? rawPrompt.trim() : '';
if (!prompt) throw new Error('claude-code host requires a non-empty prompt');
runClaudeCode({ prompt, repoRoot }); Type guard
function isNonEmptyPrompt(v) {
return typeof v === 'string' && v.trim().length > 0;
} Try / catch
try {
await runClaudeCode({ prompt, repoRoot });
} catch (e) {
if (e instanceof TypeError && e.message === 'prompt must be a non-empty string') {
// your prompt builder produced nothing; fix the builder, do not retry blindly
throw new Error('prompt construction failed: task description was empty');
}
throw e;
} Prevention
- Build prompts in one place and assert non-empty after trimming.
- Never feed unopened/blank files or empty stdin straight into the host adapter.
- Log the final prompt (it is the unit of delegation) before spawning.
When it happens
Trigger: runClaudeCode({}) (prompt undefined), runClaudeCode({ prompt: '' }), runClaudeCode({ prompt: ' ' }) (whitespace-only fails .trim()), prompt built from a template that yields '' when a variable is missing.
Common situations: Piping an empty stdin/file into the prompt builder; conditionally concatenating prompt parts where every branch was skipped; passing a prompt object { text } instead of the 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/6a24c5755d6a10a5.
Report an issue: GitHub.