affaan-m/ECC · error · Error
Unknown argument: ${arg}
Error message
Unknown argument: ${arg} What it means
Thrown by sessions-cli.js parseArgs when a token is not an accepted flag (--db, --json, --limit, --help/-h) and is not the first bare positional (which is captured as the session id). Any second positional, or any unknown flag, is rejected.
Source
Thrown at scripts/sessions-cli.js:43
};
for (let index = 0; index < args.length; index += 1) {
const arg = args[index];
if (arg === '--db') {
parsed.dbPath = args[index + 1] || null;
index += 1;
} else if (arg === '--json') {
parsed.json = true;
} else if (arg === '--limit') {
parsed.limit = args[index + 1] || null;
index += 1;
} else if (arg === '--help' || arg === '-h') {
parsed.help = true;
} else if (!arg.startsWith('--') && !parsed.sessionId) {
parsed.sessionId = arg;
} else {
throw new Error(`Unknown argument: ${arg}`);
}
}
return parsed;
}
function printSessionList(payload) {
console.log('Recent sessions:\n');
if (payload.sessions.length === 0) {
console.log('No sessions found.');
return;
}
for (const session of payload.sessions) {
console.log(`- ${session.id} [${session.harness}/${session.adapterId}] ${session.state}`);
console.log(` Repo: ${session.repoRoot || '(unknown)'}`);
console.log(` Started: ${session.startedAt || '(unknown)'}`);View on GitHub (pinned to 01e15490f0)
Solutions
- Pass at most one positional session id.
- Run `node scripts/sessions-cli.js --help` to confirm accepted flags.
- Quote ids that contain spaces or special characters.
- Move --json / --limit before the positional id to keep the command unambiguous.
Example fix
# before node scripts/sessions-cli.js abc123 def456 --json # after node scripts/sessions-cli.js --json abc123
Defensive patterns
Strategy: validation
Validate before calling
const ALLOWED = new Set(['--db', '--json', '--limit', '--help', '-h']);
const tokens = process.argv.slice(2);
const unknown = tokens.filter(t => t.startsWith('--') && !ALLOWED.has(t));
const positionals = tokens.filter(t => !t.startsWith('--'));
if (unknown.length || positionals.length > 1) { console.error('Bad sessions-cli invocation'); process.exit(2); } Try / catch
try { parseArgs(process.argv); } catch (err) { console.error(err.message); process.exit(2); } Prevention
- Pass at most one positional id; route everything else through flags.
- Pre-validate token shape in a thin wrapper before delegating.
When it happens
Trigger: Passing two session ids, a flag from another script (e.g. --format), or a typo like `--limt`. The first non-`--` token becomes the session id and a second one triggers the error.
Common situations: Pasting a session id with a trailing path; combining sessions-cli flags with setup.js flags; passing --json before the id in a way that leaves a stray token.
Related errors
- --write requires a path
- Unknown argument: ${arg}
- Invalid ${flag}: expected a single cache path segment
- Unknown argument: ${arg}
- Missing value for ${arg}
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/37cd53e5b8851a4a.
Report an issue: GitHub.