{"record":{"id":"da7acaf24af2313f","repo":"ruvnet/RuView","slug":"prompt-must-be-a-non-empty-string-da7aca","errorCode":null,"errorMessage":"prompt must be a non-empty string","messagePattern":"prompt must be a non-empty string","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"harness/ruview/src/hosts/codex.js","lineNumber":12,"sourceCode":"// SPDX-License-Identifier: MIT\nimport { runProcess } from '../process-runner.js';\nimport { assertTrustedRuViewRepo } from '../repo-trust.js';\nexport function buildCodexArgs(root, { write = false } = {}) {\n  return ['exec', '-', '-C', root, '--sandbox', write ? 'workspace-write' : 'read-only',\n    '--ephemeral', '--json', '--strict-config', '--ignore-user-config', '--ignore-rules'];\n}\nexport async function runCodex({\n  prompt, repoRoot, trustedRoot = repoRoot, allowWrite = false, confirm = false,\n  command = 'codex', commandArgs = [], ...runOptions\n}) {\n  if (typeof prompt !== 'string' || !prompt.trim()) throw new TypeError('prompt must be a non-empty string');\n  const root = assertTrustedRuViewRepo(repoRoot, { trustedRoot });\n  const write = allowWrite === true && confirm === true;\n  return runProcess(command, [...commandArgs, ...buildCodexArgs(root, { write })], { ...runOptions, cwd: root, input: prompt });\n}\nexport default Object.freeze({ name: 'codex', run: runCodex, buildArgs: buildCodexArgs });\n","sourceCodeStart":1,"sourceCodeEnd":18,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/harness/ruview/src/hosts/codex.js#L1-L18","documentation":"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.","triggerScenarios":"runCodex({}) (prompt undefined), runCodex({ prompt: '' }), runCodex({ prompt: '\\n  ' }), or reading the prompt from an empty file/stdin before passing it through.","commonSituations":"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.","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 })."],"exampleFix":"// before\nrunCodex({ prompt: readFileSync(promptFile, 'utf8'), repoRoot }) // file was empty\n// after\nconst prompt = readFileSync(promptFile, 'utf8').trim();\nif (!prompt) throw new Error(`prompt file is empty: ${promptFile}`);\nrunCodex({ prompt, repoRoot });","handlingStrategy":"validation","validationCode":"const prompt = typeof rawPrompt === 'string' ? rawPrompt.trim() : '';\nif (!prompt) throw new Error('codex host requires a non-empty prompt');\nrunCodex({ prompt, repoRoot });","typeGuard":"function isNonEmptyPrompt(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  await runCodex({ prompt, repoRoot });\n} catch (e) {\n  if (e instanceof TypeError && e.message === 'prompt must be a non-empty string') {\n    throw new Error('codex delegation aborted: prompt was empty');\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["validation","host-adapter","codex","delegation","ruview-harness"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}