tinyhumansai/openhuman · error · Error

missing value for ${arg}

Error message

missing value for ${arg}

What it means

parseArgs() in scripts/debug/agent-prepare-context-audit.mjs walks argv with a next() helper that consumes the following token for value-taking options (--core-url, --token, --workspace, --model, --query, --scout-prompt-file, --thread-prefix, --max-print-chars, --rpc-timeout-ms). When the option is the last token on the command line, argv[++i] is undefined and it throws 'missing value for <flag>'.

Source

Thrown at scripts/debug/agent-prepare-context-audit.mjs:119

    queries: [],
    raw: false,
    scoutPromptFile: "",
    threadPrefix: `apc-audit-${randomBytes(3).toString("hex")}`,
    seedTranscript: true,
    maxPrintChars: 4000,
    rpcTimeoutMs: 600_000,
    spawnCore: false,
    keepWorkspace: false,
    json: false,
    verbose: false,
    coreUrlExplicit: Boolean(process.env.OPENHUMAN_CORE_RPC_URL),
    workspaceExplicit: Boolean(process.env.OPENHUMAN_WORKSPACE),
  };
  for (let i = 0; i < argv.length; i += 1) {
    const arg = argv[i];
    const next = () => {
      const value = argv[++i];
      if (value === undefined) throw new Error(`missing value for ${arg}`);
      return value;
    };
    switch (arg) {
      case "--core-url":
        opts.coreUrl = next();
        opts.coreUrlExplicit = true;
        break;
      case "--token":
        opts.token = next();
        break;
      case "--workspace":
        opts.workspace = next();
        opts.workspaceExplicit = true;
        break;
      case "--model":
        opts.model = next();
        break;
      case "--query":

View on GitHub (pinned to a221052e0d)

Solutions

  1. Supply the missing value right after the flag: --token <value>
  2. If the flag is unwanted, remove it entirely rather than leaving it dangling
  3. For values that may be empty or env-derived, pass them via environment (OPENHUMAN_CORE_TOKEN etc.) instead of the flag form

Example fix

# before
$ node scripts/debug/agent-prepare-context-audit.mjs --token
Error: missing value for --token

# after
$ node scripts/debug/agent-prepare-context-audit.mjs --token "$OPENHUMAN_CORE_TOKEN"
Defensive patterns

Strategy: validation

Validate before calling

// Lint argv before executing: every value-taking flag must have a following token
const VALUE_FLAGS = new Set(["--core-url", "--token", "--workspace", "--model", "--query", "--scout-prompt-file", "--thread-prefix", "--max-print-chars", "--rpc-timeout-ms"]);
for (let i = 0; i < argv.length; i++) {
  if (VALUE_FLAGS.has(argv[i]) && (i + 1 >= argv.length || argv[i + 1].startsWith("--"))) {
    console.error(`${argv[i]} requires a value`); process.exit(2);
  }
}

Prevention

When it happens

Trigger: Invoking the audit script with a value-taking flag at the end of the command with nothing after it, e.g. `node scripts/debug/agent-prepare-context-audit.mjs --token` or `... --query`. Also triggered when a quoted empty-string argument is stripped by shell misquoting and the next token is genuinely absent.

Common situations: Incrementally building a long debug command line and forgetting to paste the value; copy-pasting from docs where the placeholder value was on a wrapped line; CI scripts concatenating flag arrays where an undefined env var expands to nothing.

Related errors


AI-assisted analysis of tinyhumansai/openhuman@a221052e0d (2026-08-16). Data as JSON: /api/errors/c767b0bb71cdc612. Report an issue: GitHub.