Hmbown/CodeWhale · error · Error

unknown argument: ${arg}

Error message

unknown argument: ${arg}

What it means

The CLI argument parser in integrations/telegram-bridge/scripts/validate-config.mjs walks process.argv and recognizes only --allow-remote-runtime, --json, -h and --help. Any other token falls into the default case and throws `unknown argument: ${arg}` before any config or environment validation runs. It is a pure usage error: the message echoes back the exact offending token.

Source

Thrown at integrations/telegram-bridge/scripts/validate-config.mjs:78

      case "--workspace-root":
        parsed.workspaceRoot = argv[++index];
        break;
      case "--check-filesystem":
        parsed.checkFilesystem = true;
        break;
      case "--allow-remote-runtime":
        parsed.requireLocalRuntime = false;
        break;
      case "--json":
        parsed.json = true;
        break;
      case "-h":
      case "--help":
        printHelp();
        process.exit(0);
        break;
      default:
        throw new Error(`unknown argument: ${arg}`);
    }
  }
  return parsed;
}

async function appendFilesystemChecks(result, env, args) {
  const workspace = envFirst(env, "CODEWHALE_WORKSPACE", "DEEPSEEK_WORKSPACE");
  if (workspace) {
    await checkReadableDirectory(result, workspace, "workspace");
  }

  const threadMapPath = cleanEnvValue(env.TELEGRAM_THREAD_MAP_PATH);
  if (threadMapPath) {
    const parent = path.dirname(threadMapPath);
    await checkWritableDirectory(result, parent, "thread map directory");
  }

  if (args.env) {

View on GitHub (pinned to 8880682c63)

Solutions

  1. Run `node scripts/validate-config.mjs --help` to list the accepted flags, then correct the command line
  2. Remove positional values — `--json` and `--allow-remote-runtime` are boolean flags that take no value
  3. If extending the script, add the new case to the switch at validate-config.mjs:78 and keep printHelp in sync

Example fix

# before
node scripts/validate-config.mjs --json true
# after
node scripts/validate-config.mjs --json
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED = new Set(['--allow-remote-runtime', '--json', '-h', '--help']);
const offending = process.argv.slice(2).filter((a) => !ALLOWED.has(a));
if (offending.length) {
  console.error(`unsupported argument(s): ${offending.join(' ')} — see --help`);
  process.exit(2);
}

Try / catch

try {
  const parsed = parseArgs(process.argv.slice(2));
} catch (error) {
  if (/^unknown argument:/.test(error.message)) {
    printHelp();
    process.exit(2);
  }
  throw error;
}

Prevention

When it happens

Trigger: Running `node scripts/validate-config.mjs` with a misspelled flag (--allow-remote, --verbose), a value passed as a separate positional (--json true), or an env-style argument (TELEGRAM_BOT_TOKEN=...).

Common situations: Copy-pasting a command line from another bridge's docs; passing flags that belong to src/index.mjs rather than the validator; shell aliases or scripts that append extra arguments.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16). Data as JSON: /api/errors/e673709667a2ba53. Report an issue: GitHub.