affaan-m/ECC · error · Error
Unknown argument: ${flag}
Error message
Unknown argument: ${flag} What it means
Thrown by scripts/assignOption in scripts/work-items.js if a flag that is a member of the VALUE_FLAGS set reaches the final else branch — meaning it was caught by `VALUE_FLAGS.has(arg)` in parseArgs but has no corresponding handler in assignOption's if-else chain. In the current code every VALUE_FLAGS entry has a handler, so this throw is a defensive invariant guard: it exists to catch a future edit that adds a flag to VALUE_FLAGS without adding its assignment branch. It is effectively unreachable under the present flag set.
Source
Thrown at scripts/work-items.js:80
function assignOption(options, flag, value) {
if (flag === '--as') options.claimAs = value;
else if (flag === '--db') options.dbPath = value;
else if (flag === '--github-repo') options.githubRepo = value;
else if (flag === '--id') options.id = value;
else if (flag === '--limit') options.limit = value;
else if (flag === '--metadata-json') options.metadataJson = value;
else if (flag === '--owner') options.owner = value;
else if (flag === '--priority') options.priority = value;
else if (flag === '--repo' && options.command === 'sync-github') options.githubRepo = value;
else if (flag === '--repo' || flag === '--repo-root') options.repoRoot = value;
else if (flag === '--session' || flag === '--session-id') options.sessionId = value;
else if (flag === '--source') options.source = value;
else if (flag === '--source-id') options.sourceId = value;
else if (flag === '--status') options.status = value;
else if (flag === '--title') options.title = value;
else if (flag === '--url') options.url = value;
else throw new Error(`Unknown argument: ${flag}`);
}
function parseArgs(argv) {
const args = argv.slice(2);
const parsed = {
command: 'list',
dbPath: null,
help: false,
json: false,
limit: 20,
positionals: []
};
if (args[0] && !args[0].startsWith('-')) {
parsed.command = args.shift();
}
for (let index = 0; index < args.length; index += 1) {View on GitHub (pinned to 01e15490f0)
Solutions
- If you are extending work-items.js, ensure every new entry in VALUE_FLAGS has a corresponding branch in assignOption.
- If you hit this as an end user, you are likely on a build where a flag was half-wired; report it or pin to a known-good ECC version.
- Run the work-items test suite after adding a flag to confirm assignOption is covered.
Example fix
// before (flag added to VALUE_FLAGS but not handled) const VALUE_FLAGS = new Set([..., '--label']); // assignOption has no branch for --label -> throws // after else if (flag === '--label') options.label = value;
Defensive patterns
Strategy: validation
Validate before calling
// For maintainers: keep VALUE_FLAGS and assignOption in sync
const VALUE_FLAGS = require('./work-items-flags'); // single source of truth
function assertAssignOptionCoversAll() {
// each VALUE_FLAGS entry must have a branch in assignOption
const sample = [...VALUE_FLAGS];
const opts = {};
for (const flag of sample) {
assignOption(opts, flag, 'x'); // throws 472 if a branch is missing
}
} Prevention
- When adding a flag to VALUE_FLAGS, add the assignOption branch in the same edit.
- Add a unit test that calls assignOption for every VALUE_FLAGS member.
- Treat the line-80 throw as a build-time tripwire, not a runtime path.
When it happens
Trigger: Not triggerable through normal CLI use in the current version. Would only fire if a developer added an entry to the VALUE_FLAGS set (lines 9-27) but forgot to add a matching `else if` branch in assignOption, then passed that new flag on the command line.
Common situations: A maintainer extending work-items.js with a new value flag (e.g. --label) who updates VALUE_FLAGS but not assignOption; this error is the safety net that makes the omission loud during testing of the new flag.
Related errors
- Missing value for ${arg}
- Unknown argument: ${arg}
- --write requires a path
- Unknown argument: ${arg}
- Invalid ${flag}: expected a single cache path segment
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/2d57b3e68a3af636.
Report an issue: GitHub.