affaan-m/ECC · error · Error

Invalid value: expected a path

Error message

Invalid ${name} value: expected a path

What it means

pathValueAfter extracts the value following a CLI flag (e.g. --repo-root) in the control-pane server's argument parser and rejects values that are missing, empty, or start with '-' (i.e. another flag was consumed as the value). It ensures path-typed options receive an actual path string.

Solutions

  1. Provide the path immediately after the flag: --repo-root /path/to/repo
  2. Check that any shell variable holding the path is non-empty and quoted
  3. Reorder arguments so the path value precedes other flags
  4. Run with --help to confirm the flag names and expected values

Example fix

// before
$ node server.js --repo-root $ROOT --port 8765   # ROOT empty
// after
$ node server.js --repo-root "$PWD" --port 8765
Defensive patterns

Strategy: validation

Validate before calling

const idx = args.indexOf('--repo-root');
const val = idx !== -1 ? args[idx + 1] : null;
if (val !== null && (!val || val.startsWith('-'))) throw new Error('missing value for --repo-root');

Type guard

const isPathValue = (v) => typeof v === 'string' && v.length > 0 && !v.startsWith('-');

Try / catch

try { const opts = parseArgs(process.argv); } catch (e) {
  if (String(e.message).includes('expected a path')) console.error('Provide a non-empty path after path flags');
  else throw e;
}

Prevention

When it happens

Trigger: Running the server as `node server.js --repo-root` (no value), `--repo-root --port 8765` (next flag eaten as value), or `--repo-root ""`.

Common situations: Shell variable for the path is empty/unset ($REPO_ROOT expands to nothing); flag order mistakes; quoting errors that drop the argument.

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/94110151d1aea91d. Report an issue: GitHub.

Appendix: source

Thrown at scripts/lib/control-pane/server.js:60

    '',
    'Options:',
    '  --state-db <path>  Read agent work items from an ECC state-store database',
    '  --read-only        Disable action execution endpoints',
    '  --no-open          Do not open a browser after the server starts',
    '  --help             Show this help'
  ].join('\n');
}

function valueAfter(args, name) {
  const index = args.indexOf(name);
  return index >= 0 ? args[index + 1] : null;
}

function pathValueAfter(args, name) {
  const value = valueAfter(args, name);
  if (value === null) return null;
  if (!value || value.startsWith('-')) {
    throw new Error(`Invalid ${name} value: expected a path`);
  }
  return value;
}

function parseArgs(argv) {
  const args = argv.slice(2);
  const help = args.includes('--help') || args.includes('-h');
  const host = valueAfter(args, '--host') || '127.0.0.1';
  const portValue = valueAfter(args, '--port') || '8765';
  const port = Number.parseInt(portValue, 10);
  if (!Number.isFinite(port) || port < 0 || port > 65535) {
    throw new Error(`Invalid --port value: ${portValue}`);
  }

  return {
    help,
    host,
    port,

View on GitHub (pinned to 8321021c54)