affaan-m/ECC · error · Error

Missing value for --db

Error message

Missing value for --db

What it means

Thrown by scripts/status.js when --db appears in argv but no value follows it. The parser reads the next token with `args[index + 1] || null`; if --db is the last token (or the next token is an empty string), dbPath stays null and the post-parse guard `args.includes('--db') && !parsed.dbPath` fires. The script needs a concrete SQLite path to query the state store, so an empty value cannot be defaulted.

Source

Thrown at scripts/status.js:63

    } else if (arg === '--write') {
      parsed.writePath = args[index + 1] || null;
      index += 1;
    } else if (arg === '--limit') {
      parsed.limit = args[index + 1] || null;
      index += 1;
    } else if (arg === '--help' || arg === '-h') {
      parsed.help = true;
    } else {
      throw new Error(`Unknown argument: ${arg}`);
    }
  }

  if (parsed.json && parsed.markdown) {
    throw new Error('Choose only one output format: --json or --markdown');
  }

  if (args.includes('--db') && !parsed.dbPath) {
    throw new Error('Missing value for --db');
  }

  if (args.includes('--write') && !parsed.writePath) {
    throw new Error('Missing value for --write');
  }

  if (args.includes('--limit') && !parsed.limit) {
    throw new Error('Missing value for --limit');
  }

  return parsed;
}

function printActiveSessions(section) {
  console.log(`Active sessions: ${section.activeCount}`);
  if (section.sessions.length === 0) {
    console.log('  - none');
    return;

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Supply the path immediately after --db: `node scripts/status.js --db /home/user/.ecc/state.db`.
  2. If you want the default database location, omit --db entirely rather than passing it empty.
  3. Fix the wrapper script so it only appends `--db <path>` when the path variable is non-empty.

Example fix

// before
node scripts/status.js --db

// after
node scripts/status.js --db /home/user/.ecc/state.db
Defensive patterns

Strategy: validation

Validate before calling

// Only append --db <path> when the path is a non-empty string
const dbPath = process.env.ECC_DB_PATH;
const args = ['--json'];
if (dbPath) {
  args.push('--db', dbPath);
}
// If dbPath is unset, status.js uses its default location

Prevention

When it happens

Trigger: `node scripts/status.js --db` (flag is last token); `node scripts/status.js --db --json` (next token is another flag which is consumed as the value, then the guard catches dbPath pointing at a flag name — note here the value becomes the literal string '--json' which is truthy, so this specific case actually does NOT throw; the throw fires only when the value is falsy). The pure trigger is --db with no following token at all.

Common situations: A wrapper script conditionally appends `--db` but forgets to append the path variable when it is empty; trailing --db at end of line after editing a command; environment variable for the db path being unset so the constructed flag string ends with `--db`.

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/44cc44a4eb9f7295. Report an issue: GitHub.