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

Unknown exec inject argument: ${arg}

Error message

Unknown exec inject argument: ${arg}

What it means

Usage error from parseExecInjectArgs when a token starts with '-' but matches no recognized flag (--json, --prompt[=], --prompt-file[=], --actor[=]) and a prompt has already been set. The parser treats unknown dash-prefixed tokens as errors rather than silently ignoring them.

Source

Thrown at src/exec/followup.ts:399

    } else if (arg === "--prompt-file") {
      const value = rest[i + 1];
      if (!value) throw new Error("Missing path after --prompt-file");
      prompt = readFileSyncForCli(value);
      i += 1;
    } else if (arg.startsWith("--prompt-file=")) {
      prompt = readFileSyncForCli(arg.slice("--prompt-file=".length));
    } else if (arg === "--actor") {
      const value = rest[i + 1];
      if (!value) throw new Error("Missing value after --actor");
      actor = value;
      i += 1;
    } else if (arg.startsWith("--actor=")) {
      actor = arg.slice("--actor=".length);
    } else if (!arg.startsWith("-") && !prompt) {
      prompt = [arg, ...rest.slice(i + 1)].join(" ");
      break;
    } else {
      throw new Error(`Unknown exec inject argument: ${arg}`);
    }
  }
  return { sessionId, prompt, actor, json };
}

function readFileSyncForCli(path: string): string {
  return readFileSync(path, "utf-8");
}

export async function execInjectCommand(args: string[], cwd = process.cwd()): Promise<void> {
  const parsed = parseExecInjectArgs(args);
  const result = await injectExecFollowup({
    cwd,
    sessionId: parsed.sessionId,
    prompt: parsed.prompt,
    actor: parsed.actor,
  });
  if (parsed.json) {

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Fix the flag name — check the supported set in the usage string: --prompt[=], --prompt-file[=], --actor[=], --json.
  2. Remove flags not supported by `omx exec inject`; they may belong on a parent command.
  3. If the prompt itself starts with '-', pass it with --prompt="<text>" or --prompt-file so it isn't parsed as a flag.
  4. Re-run with only documented flags to isolate the offending token.

Example fix

# before
omx exec inject "$SESSION_ID" --prompt "hi" --verbose
# throws: Unknown exec inject argument: --verbose

# after
omx exec inject "$SESSION_ID" --prompt "hi" --json
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED = new Set(['--json']);
for (const a of extraArgs) {
  if (a.startsWith('-') && !ALLOWED.has(a) && !a.startsWith('--prompt') && !a.startsWith('--actor')) {
    throw new Error(`unsupported flag ${a} for exec inject`);
  }
}

Try / catch

catch (e) { const m = e instanceof Error && e.message.match(/^Unknown exec inject argument: (.+)$/); if (m) { console.error(`unsupported flag: ${m[1]}`); process.exit(2); } throw e; }

Prevention

When it happens

Trigger: Typos like `--promt`, `--Prompt`, `--jsn`; passing unsupported flags such as `--verbose` or `--dry-run` after the prompt is set; a negative-number or dash-leading prompt fragment arriving after --prompt was already assigned; combining flags in one token like `--json --actor`.

Common situations: User assumes an unrelated global flag works on the inject subcommand; typo in scripts; upgrading from a version whose flag set differed; passing '--' separator tokens unexpectedly.

Related errors


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