Yeachan-Heo/oh-my-codex · error

Unknown state subcommand: ${subcommand} ${STATE_HELP}

Error message

Unknown state subcommand: ${subcommand}
${STATE_HELP}

What it means

The first positional argument to the state command does not match any subcommand in STATE_OPERATION_MAP. Valid subcommands are listed in the printed STATE_HELP text.

Source

Thrown at src/cli/state.ts:83

}

export async function stateCommand(
  args: string[],
  deps: StateCommandDependencies = {},
): Promise<void> {
  const stdout = deps.stdout ?? ((line: string) => console.log(line));
  const stderr = deps.stderr ?? ((line: string) => console.error(line));
  const execute = deps.execute ?? executeStateOperation;

  const subcommand = args[0];
  if (!subcommand || isHelpArg(subcommand)) {
    stdout(STATE_HELP);
    return;
  }

  const operation = STATE_OPERATION_MAP[subcommand];
  if (!operation) {
    throw new Error(`Unknown state subcommand: ${subcommand}\n${STATE_HELP}`);
  }

  if (isHelpArg(args[1])) {
    stdout(STATE_HELP);
    return;
  }

  let inputValue: string | undefined;
  let inputFileValue: string | undefined;
  let modeValue: string | undefined;
  let json = false;
  for (let index = 1; index < args.length; index += 1) {
    const arg = args[index];
    if (arg === '--json') {
      json = true;
      continue;
    }
    if (arg === '--input') {

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Run `state --help` to list valid subcommands
  2. Fix the typo (e.g. `state set ...`)
  3. Pin/align the CLI version your scripts were written for

Example fix

# before
state writestate --input '{}'
# after
state set --input '{}'
Defensive patterns

Strategy: type-guard

Validate before calling

const KNOWN = new Set(Object.keys(STATE_OPERATION_MAP));
if (!KNOWN.has(subcommand)) {
  console.error(`unknown subcommand; valid: ${[...KNOWN].join(', ')}`);
  process.exit(1);
}

Type guard

const isStateSubcommand = (s: string): s is keyof typeof STATE_OPERATION_MAP =>
  s in STATE_OPERATION_MAP;

Prevention

When it happens

Trigger: `state sett foo` (typo), `state update` when only get/set/clear-style operations exist, or `state` with a stray flag as first token.

Common situations: Typos, renaming of subcommands across versions, scripts written against an older CLI surface.

Related errors


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