affaan-m/ECC · error · Error

Invalid inventory arguments. Use --help.

Error message

Invalid inventory arguments. Use --help.

What it means

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.

Solutions

  1. Run with --help to see the supported flags.
  2. Use only --live, --manifest <path>, --coordination <path>, --now and provide a non-flag value after value-flags.
  3. Fix flag spelling and ordering in any wrapper scripts or CI invocations.

Example fix

// before
node scripts/coordination-inventory.js --manifests tasks.json
// after
node scripts/coordination-inventory.js --manifest tasks.json
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED = ['--live', '--manifest', '--coordination', '--now'];
const bad = argv.filter(a => a.startsWith('--') && !ALLOWED.includes(a));
if (bad.length) { console.error('Unknown flags: ' + bad.join(' ')); process.exit(1); }

Type guard

function isKnownInventoryFlag(flag) { return ['--live','--manifest','--coordination','--now'].includes(flag); }

Try / catch

try {
  runInventory(argv);
} catch (e) {
  if (e.message === 'Invalid inventory arguments. Use --help.') {
    console.error(e.message);
    runInventory(['--help']);
  } else throw e;
}

Prevention

When it happens

Trigger: 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 `--`.

Common situations: 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).

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/53b87d377281c7f7. Report an issue: GitHub.

Appendix: source

Thrown at scripts/coordination-inventory.js:15

#!/usr/bin/env node
'use strict';
const { normalizeManifest, buildInventory, collectResources, collectTaskFiles, readJson } = require('./lib/coordination-inventory');

function main(argv = process.argv.slice(2)) {
  if (argv.length === 1 && ['--help', '-h'].includes(argv[0])) {
    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');
    return;
  }
  const options = {};
  for (let i = 0; i < argv.length; i += 1) {
    const flag = argv[i];
    if (flag === '--live' && !options.live) options.live = true;
    else if (['--manifest', '--coordination', '--now'].includes(flag) && !options[flag.slice(2)] && argv[i+1] && !argv[i+1].startsWith('--')) options[flag.slice(2)] = argv[++i];
    else throw new Error('Invalid inventory arguments. Use --help.');
  }
  let manifest = options.manifest ? readJson(options.manifest) : { version: 1, tasks: [], repositories: [], leases: [] };
  let discovery = null;
  if (options.coordination) {
    discovery = collectTaskFiles(options.coordination);
    // Duplicate IDs are rejected; never silently replace declared ownership.
    manifest = { ...manifest, tasks: [...(manifest.tasks || []), ...discovery.tasks] };
  }
  const normalized = normalizeManifest(manifest);
  const resources = options.live ? collectResources(normalized.tasks) : undefined;
  const report = buildInventory(manifest, { now: options.now, resources });
  if (discovery) report.discovery = { status: discovery.status, unreadable: discovery.unreadable };
  process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
}
if (require.main === module) {
  try { main(); } catch { process.stderr.write('Inventory failed: invalid arguments or unreadable/invalid input. Use --help.\n'); process.exitCode = 1; }
}
module.exports = { main };

View on GitHub (pinned to 8321021c54)