Yeachan-Heo/oh-my-codex · error · Error

--answer-question-id requires --answer

Error message

--answer-question-id requires --answer

What it means

Thrown by the omx question CLI when --answer-question-id is provided without --answer. Answering a recorded question by ID requires the answer payload, so the command refuses to run with only half of the pair.

Source

Thrown at src/cli/question.ts:254

      : { clearReason: 'error' },
  );
}

export async function questionCommand(args: string[]): Promise<void> {
  const parsed = parseQuestionArgs(args);
  if (parsed.help || args.length === 0) {
    console.log(QUESTION_HELP);
    return;
  }

  if (parsed.ui) {
    if (!parsed.statePath) throw new Error('--ui requires --state-path');
    await runQuestionUi(parsed.statePath);
    return;
  }

  if (parsed.answerQuestionId) {
    if (!parsed.answer) throw new Error('--answer-question-id requires --answer');
    let answerPayload: unknown;
    try {
      answerPayload = JSON.parse(parsed.answer);
    } catch (error) {
      throw new Error(`--answer must be valid JSON: ${(error as Error).message}`);
    }
    try {
      const { record, recordPath } = await submitQuestionAnswerById(
        process.cwd(),
        parsed.answerQuestionId,
        answerPayload,
        { sessionId: parsed.sessionId },
      );
      printJson({
        ok: true,
        question_id: record.question_id,
        session_id: record.session_id,
        status: record.status,

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Add the --answer flag with a JSON payload: `omx question --answer-question-id <id> --answer '{"choice":"yes"}'`
  2. Verify flag names with `omx question --help` — a typo like --answers is silently ignored
  3. If scripting, check both flags are set before invoking the CLI

Example fix

# before
omx question --answer-question-id q_123
# after
omx question --answer-question-id q_123 --answer '{"choice":"yes"}'
Defensive patterns

Strategy: validation

Validate before calling

const args = ['question', '--answer-question-id', id];
if (!answerJson || !answerJson.trim()) {
  throw new Error('answer payload is required when answering a question');
}
args.push('--answer', answerJson);
await runQuestionCli(args);

Type guard

function hasCompleteAnswerFlags(parsed: { answerQuestionId?: string; answer?: string }): boolean {
  return !parsed.answerQuestionId || Boolean(parsed.answer && parsed.answer.length > 0);
}

Prevention

When it happens

Trigger: Running `omx question --answer-question-id <id>` without also passing `--answer <json>`, i.e. parsed.answerQuestionId is truthy while parsed.answer is empty.

Common situations: Shell scripts that pass the question ID but forget the answer, quoting bugs that swallow the --answer value, or copy-pasting an example command that omits the flag.

Related errors


AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27). Data as JSON: /api/errors/df7a6f270370dfbc. Report an issue: GitHub.