{"record":{"id":"53b87d377281c7f7","repo":"affaan-m/ECC","slug":"invalid-inventory-arguments-use-help","errorCode":null,"errorMessage":"Invalid inventory arguments. Use --help.","messagePattern":"Invalid inventory arguments\\. Use --help\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/coordination-inventory.js","lineNumber":15,"sourceCode":"#!/usr/bin/env node\n'use strict';\nconst { normalizeManifest, buildInventory, collectResources, collectTaskFiles, readJson } = require('./lib/coordination-inventory');\n\nfunction main(argv = process.argv.slice(2)) {\n  if (argv.length === 1 && ['--help', '-h'].includes(argv[0])) {\n    process.stdout.write('Usage: node scripts/coordination-inventory.js [--manifest file.json] [--coordination directory] [--live] [--now ISO-UTC]\\nRead-only JSON inventory. Live probes only OS memory and declared PIDs. No processes are executed from input.\\n');\n    return;\n  }\n  const options = {};\n  for (let i = 0; i < argv.length; i += 1) {\n    const flag = argv[i];\n    if (flag === '--live' && !options.live) options.live = true;\n    else if (['--manifest', '--coordination', '--now'].includes(flag) && !options[flag.slice(2)] && argv[i+1] && !argv[i+1].startsWith('--')) options[flag.slice(2)] = argv[++i];\n    else throw new Error('Invalid inventory arguments. Use --help.');\n  }\n  let manifest = options.manifest ? readJson(options.manifest) : { version: 1, tasks: [], repositories: [], leases: [] };\n  let discovery = null;\n  if (options.coordination) {\n    discovery = collectTaskFiles(options.coordination);\n    // Duplicate IDs are rejected; never silently replace declared ownership.\n    manifest = { ...manifest, tasks: [...(manifest.tasks || []), ...discovery.tasks] };\n  }\n  const normalized = normalizeManifest(manifest);\n  const resources = options.live ? collectResources(normalized.tasks) : undefined;\n  const report = buildInventory(manifest, { now: options.now, resources });\n  if (discovery) report.discovery = { status: discovery.status, unreadable: discovery.unreadable };\n  process.stdout.write(`${JSON.stringify(report, null, 2)}\\n`);\n}\nif (require.main === module) {\n  try { main(); } catch { process.stderr.write('Inventory failed: invalid arguments or unreadable/invalid input. Use --help.\\n'); process.exitCode = 1; }\n}\nmodule.exports = { main };","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/coordination-inventory.js#L1-L33","documentation":"main() in scripts/coordination-inventory.js parses argv with a strict allowlist: only --live, --manifest, --coordination, and --now (each with a value where required) are accepted; any other flag or malformed combination throws immediately. This prevents typos from being silently ignored.","triggerScenarios":"Running the inventory script with an unrecognized flag, a recognized flag missing its required value (e.g. `--manifest` as the last arg), or a value that itself starts with `--`.","commonSituations":"Typos like `--manifesst`; copying flags from another script; forgetting the file path after --manifest/--coordination; using flags this script does not support (e.g. --json).","solutions":["Run with --help to see the supported flags.","Use only --live, --manifest <path>, --coordination <path>, --now and provide a non-flag value after value-flags.","Fix flag spelling and ordering in any wrapper scripts or CI invocations."],"exampleFix":"// before\nnode scripts/coordination-inventory.js --manifests tasks.json\n// after\nnode scripts/coordination-inventory.js --manifest tasks.json","handlingStrategy":"validation","validationCode":"const ALLOWED = ['--live', '--manifest', '--coordination', '--now'];\nconst bad = argv.filter(a => a.startsWith('--') && !ALLOWED.includes(a));\nif (bad.length) { console.error('Unknown flags: ' + bad.join(' ')); process.exit(1); }","typeGuard":"function isKnownInventoryFlag(flag) { return ['--live','--manifest','--coordination','--now'].includes(flag); }","tryCatchPattern":"try {\n  runInventory(argv);\n} catch (e) {\n  if (e.message === 'Invalid inventory arguments. Use --help.') {\n    console.error(e.message);\n    runInventory(['--help']);\n  } else throw e;\n}","preventionTips":["Always provide a file path immediately after --manifest/--coordination.","Keep wrapper scripts in sync with the flag allowlist.","Test CI invocations after any script change."],"tags":["cli","argument-parsing","usage"],"backgroundTag":"invalid-cli-argument","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}