{"record":{"id":"44cc44a4eb9f7295","repo":"affaan-m/ECC","slug":"missing-value-for-db","errorCode":null,"errorMessage":"Missing value for --db","messagePattern":"Missing value for --db","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/status.js","lineNumber":63,"sourceCode":"    } else if (arg === '--write') {\n      parsed.writePath = args[index + 1] || null;\n      index += 1;\n    } else if (arg === '--limit') {\n      parsed.limit = args[index + 1] || null;\n      index += 1;\n    } else if (arg === '--help' || arg === '-h') {\n      parsed.help = true;\n    } else {\n      throw new Error(`Unknown argument: ${arg}`);\n    }\n  }\n\n  if (parsed.json && parsed.markdown) {\n    throw new Error('Choose only one output format: --json or --markdown');\n  }\n\n  if (args.includes('--db') && !parsed.dbPath) {\n    throw new Error('Missing value for --db');\n  }\n\n  if (args.includes('--write') && !parsed.writePath) {\n    throw new Error('Missing value for --write');\n  }\n\n  if (args.includes('--limit') && !parsed.limit) {\n    throw new Error('Missing value for --limit');\n  }\n\n  return parsed;\n}\n\nfunction printActiveSessions(section) {\n  console.log(`Active sessions: ${section.activeCount}`);\n  if (section.sessions.length === 0) {\n    console.log('  - none');\n    return;","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/status.js#L45-L81","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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`.","solutions":["Supply the path immediately after --db: `node scripts/status.js --db /home/user/.ecc/state.db`.","If you want the default database location, omit --db entirely rather than passing it empty.","Fix the wrapper script so it only appends `--db <path>` when the path variable is non-empty."],"exampleFix":"// before\nnode scripts/status.js --db\n\n// after\nnode scripts/status.js --db /home/user/.ecc/state.db","handlingStrategy":"validation","validationCode":"// Only append --db <path> when the path is a non-empty string\nconst dbPath = process.env.ECC_DB_PATH;\nconst args = ['--json'];\nif (dbPath) {\n  args.push('--db', dbPath);\n}\n// If dbPath is unset, status.js uses its default location","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never append a value flag without also appending a non-empty value.","Guard flag construction with the variable's truthiness.","Prefer omitting --db to letting the script pick its default over passing it empty."],"tags":["cli","argument-parsing","missing-value","status","database"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}