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

omx question requires --input in normal mode

Error message

omx question requires --input in normal mode

What it means

The question command's normal (non-UI, non-answer) mode requires an --input flag containing the question specification JSON. Without it there is nothing to normalize or evaluate, so the command aborts.

Source

Thrown at src/cli/question.ts:292

        record_path: recordPath,
      }, parsed.json);
    } catch (error) {
      const code = error instanceof QuestionSubmitError ? error.code : 'question_submit_failed';
      printJson({
        ok: false,
        question_id: parsed.answerQuestionId,
        session_id: parsed.sessionId,
        error: {
          code,
          message: extractErrorMessage(error),
        },
      }, parsed.json);
      process.exitCode = 1;
    }
    return;
  }

  if (!parsed.input) throw new Error('omx question requires --input in normal mode');

  let rawInput: unknown;
  try {
    rawInput = JSON.parse(parsed.input);
  } catch (error) {
    throw new Error(`--input must be valid JSON: ${(error as Error).message}`);
  }

  const input = normalizeQuestionInput(rawInput);
  const cwd = process.cwd();
  const policy = await evaluateQuestionPolicy({
    cwd,
    explicitSessionId: input.session_id,
    questionSource: input.source,
  });
  if (!policy.allowed) {
    printJson({
      ok: false,

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Pass --input with the question spec JSON: `omx question --input '{...}'`
  2. Run `omx question --help` to see the expected modes (UI needs --ui + --state-path; answering needs --answer-question-id + --answer)
  3. Validate the built argument list in scripts before invoking

Example fix

# before
omx question
# after
omx question --input '{"question":"Deploy?","choices":["yes","no"]}'
Defensive patterns

Strategy: validation

Validate before calling

if (mode !== 'ui' && mode !== 'answer' && !inputJson) {
  throw new Error('normal question mode requires --input');
}
const argv = ['question', '--input', JSON.stringify(questionSpec)];

Type guard

type QuestionMode =
  | { kind: 'ui'; statePath: string }
  | { kind: 'answer'; id: string; answer: unknown }
  | { kind: 'normal'; input: unknown };

function resolveMode(p: ParsedArgs): QuestionMode | null {
  if (p.statePath) return { kind: 'ui', statePath: p.statePath };
  if (p.answerQuestionId) return { kind: 'answer', id: p.answerQuestionId, answer: p.answer };
  if (p.input) return { kind: 'normal', input: p.input };
  return null;
}

Prevention

When it happens

Trigger: Running `omx question` with no flags, or only flags like --json/--state-path combos that skip the earlier UI and answer branches, leaving parsed.input empty at src/cli/question.ts:292.

Common situations: Assuming question runs interactively without input, forgetting --input after drafting a question spec, or a wrapper script dropping the argument.

Related errors


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