{"record":{"id":"9220fb45a915aaf4","repo":"openai/codex-plugin-cc","slug":"provide-a-prompt-a-prompt-file-piped-stdin-or-u","errorCode":null,"errorMessage":"Provide a prompt, a prompt file, piped stdin, or use --resume-last.","messagePattern":"Provide a prompt, a prompt file, piped stdin, or use --resume-last\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/codex/scripts/codex-companion.mjs","lineNumber":482,"sourceCode":"\n  const taskMetadata = buildTaskRunMetadata({\n    prompt: request.prompt,\n    resumeLast: request.resumeLast\n  });\n\n  let resumeThreadId = null;\n  if (request.resumeLast) {\n    const latestThread = await resolveLatestTrackedTaskThread(workspaceRoot, {\n      excludeJobId: request.jobId\n    });\n    if (!latestThread) {\n      throw new Error(\"No previous Codex task thread was found for this repository.\");\n    }\n    resumeThreadId = latestThread.id;\n  }\n\n  if (!request.prompt && !resumeThreadId) {\n    throw new Error(\"Provide a prompt, a prompt file, piped stdin, or use --resume-last.\");\n  }\n\n  const result = await runAppServerTurn(workspaceRoot, {\n    resumeThreadId,\n    prompt: request.prompt,\n    defaultPrompt: resumeThreadId ? DEFAULT_CONTINUE_PROMPT : \"\",\n    model: request.model,\n    effort: request.effort,\n    sandbox: request.write ? \"workspace-write\" : \"read-only\",\n    onProgress: request.onProgress,\n    persistThread: true,\n    threadName: resumeThreadId ? null : buildPersistentTaskThreadName(request.prompt || DEFAULT_CONTINUE_PROMPT)\n  });\n\n  const rawOutput = typeof result.finalMessage === \"string\" ? result.finalMessage : \"\";\n  const failureMessage = result.error?.message ?? result.stderr ?? \"\";\n  const rendered = renderTaskResult(\n    {","sourceCodeStart":464,"sourceCodeEnd":500,"githubUrl":"https://github.com/openai/codex-plugin-cc/blob/db52e28f4d9ded852ab3942cea316258ae4ef346/plugins/codex/scripts/codex-companion.mjs#L464-L500","documentation":"After the resume lookup, executeTaskRun requires either a prompt or a resumeThreadId. If resumeLast was true but resolved no thread (and that case already threw error 8), or if resumeLast was false and prompt is empty, this guard fires. It ensures runAppServerTurn always has something to send.","triggerScenarios":"Foreground `task` invocation with no positional prompt, no --prompt-file, no piped stdin, and --resume-last either omitted or resolving to nothing. Note: for foreground tasks this check runs inside executeTaskRun, after the background path's requireTaskRequest would already have caught it.","commonSituations":"Empty invocation, stdin not actually piped (readStdinIfPiped returns empty when not a TTY-less pipe), or a prompt-file that is empty.","solutions":["Provide a prompt as a positional argument, via --prompt-file, or through piped stdin.","Use --resume-last to continue a prior task instead of a new prompt.","If using --prompt-file, confirm the file exists and is non-empty (readTaskPrompt would throw on missing file separately)."],"exampleFix":"// before\ncodex-companion.mjs task\n// after\ncodex-companion.mjs task \"refactor the parser\"","handlingStrategy":"validation","validationCode":"if (!prompt && !resumeThreadId) {\n  throw new Error('prompt or resume required');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass a prompt or --resume-last.","Verify piped stdin is actually connected before relying on it."],"tags":["cli","validation","task","missing-argument"],"backgroundTag":null,"analyzedSha":"db52e28f4d9ded852ab3942cea316258ae4ef346","analyzedAt":"2026-08-13T05:13:20.855Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}