tinyhumansai/openhuman · error · Error

unknown argument: ${arg}

Error message

unknown argument: ${arg}

What it means

prune-dev-keychain.mjs uses a strict hand-rolled parser: the only accepted arguments are `--apply` (switch from default dry-run to real run), `--file <path>` (keychain file, defaulting to $OPENHUMAN_WORKSPACE/dev-keychain.json or .openhuman[-staging]/dev-keychain.json), and `--help`/`-h`. Any other token throws `unknown argument` before anything is read or pruned.

Source

Thrown at scripts/prune-dev-keychain.mjs:52

import os from "node:os";
import path from "node:path";

/** `tempfile`'s default TempDir basename: `.tmp` + 6 random alphanumerics. */
const LEAKED_USER_ID = /^\.tmp[A-Za-z0-9]{6}$/;

function parseArgs(argv) {
  const args = { apply: false, file: null };
  for (let i = 0; i < argv.length; i += 1) {
    const arg = argv[i];
    if (arg === "--apply") {
      args.apply = true;
    } else if (arg === "--file") {
      args.file = argv[i + 1];
      i += 1;
    } else if (arg === "--help" || arg === "-h") {
      args.help = true;
    } else {
      throw new Error(`unknown argument: ${arg}`);
    }
  }
  return args;
}

function defaultKeychainPath() {
  const workspace = process.env.OPENHUMAN_WORKSPACE?.trim();
  if (workspace) return path.join(workspace, "dev-keychain.json");
  const dir =
    process.env.OPENHUMAN_APP_ENV === "staging"
      ? ".openhuman-staging"
      : ".openhuman";
  return path.join(os.homedir(), dir, "dev-keychain.json");
}

/** An entry is leaked when its user-id segment is a dead TempDir basename. */
function isLeaked(key) {
  const separator = key.indexOf(":");

View on GitHub (pinned to a221052e0d)

Solutions

  1. Run `node scripts/prune-dev-keychain.mjs --help` to see the supported flags
  2. Use `--apply` for a real run and `--file <path>` to select a non-default keychain file
  3. Pass the keychain path only via `--file`, never as a positional argument

Example fix

# before
node scripts/prune-dev-keychain.mjs ~/tmp/dev-keychain.json --force
# → Error: unknown argument: ~/tmp/dev-keychain.json

# after
node scripts/prune-dev-keychain.mjs --file ~/tmp/dev-keychain.json --apply
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED = new Set(['--apply', '--file', '--help', '-h']);
const bad = process.argv.slice(2).filter(a => !a.startsWith('-') === false && !ALLOWED.has(a) && !ALLOWED.has(process.argv[process.argv.indexOf(a) - 1]));
// simpler: whitelist-check every dash-token before delegating
const tokens = process.argv.slice(2);
const known = new Set(['--apply', '--file', '--help', '-h']);
if (tokens.some(t => t.startsWith('-') && !known.has(t))) {
  console.error('Unsupported flag — supported: --apply, --file <path>, --help');
  process.exit(2);
}

Try / catch

try {
  const args = parseArgs(process.argv.slice(2));
} catch (err) {
  if (err.message.startsWith('unknown argument')) {
    printUsage(); // supported flags: --apply, --file <path>, --help/-h
    process.exit(2);
  }
  throw err;
}

Prevention

When it happens

Trigger: Passing `--force`, `-y`, or a bare positional path (`node scripts/prune-dev-keychain.mjs ~/kc.json`); assuming flags from a sibling script exist here.

Common situations: Muscle memory from other repo scripts; trying to skip the dry-run with `-y` instead of `--apply`.

Related errors


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