{"record":{"id":"aeccb7d4c798d70e","repo":"pbakaus/impeccable","slug":"target-requires-a-path-value-use-target-path-aeccb7","errorCode":null,"errorMessage":"--target requires a path value (use --target <path> or --target=<path>)","messagePattern":"--target requires a path value \\(use --target <path> or --target=<path>\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"skill/scripts/live/roots.mjs","lineNumber":451,"sourceCode":"  if (fresh.selection) return { selection: fresh.selection, source: 'fresh' };\n  return { manifest: fresh.manifest, source: 'fresh' };\n}\n\n/**\n * Consume a `--target <path>` / `--target=<path>` pair from an argv array,\n * returning the value and removing the tokens so downstream flag parsers\n * (which do not know the option) never see them.\n */\nexport function consumeTargetArg(argv = process.argv) {\n  for (let i = 0; i < argv.length; i++) {\n    const arg = argv[i];\n    if (arg === '--target') {\n      const value = argv[i + 1];\n      // A --target with no usable value must not degrade into implicit root\n      // selection: these helpers mutate session state, and \"the most recent\n      // app\" is exactly what the caller was trying NOT to get.\n      if (typeof value !== 'string' || value === '' || value.startsWith('--')) {\n        throw new Error('--target requires a path value (use --target <path> or --target=<path>)');\n      }\n      argv.splice(i, 2);\n      return value;\n    }\n    if (typeof arg === 'string' && arg.startsWith('--target=')) {\n      const value = arg.slice('--target='.length);\n      if (value === '') {\n        throw new Error('--target requires a path value (use --target <path> or --target=<path>)');\n      }\n      argv.splice(i, 1);\n      return value;\n    }\n  }\n  return null;\n}\n\n/**\n * Entry-point guard for live CLI scripts: resolve the governing roots and","sourceCodeStart":433,"sourceCodeEnd":469,"githubUrl":"https://github.com/pbakaus/impeccable/blob/d14711ae3d1a1dd62dee61a358d27f107c51ccd0/skill/scripts/live/roots.mjs#L433-L469","documentation":"Thrown by consumeTargetArg() in live/roots.mjs when '--target' appears on the helper command line but the next token is not a usable path value. The guard explicitly refuses to fall back to implicit root selection, because these helpers mutate session state and 'most recent app' is precisely what the caller wanted to avoid. The check fails when the value is missing (end of args), empty, or itself starts with '--' (i.e. the next flag was mistaken for a path).","triggerScenarios":"A live helper CLI is invoked as '--target' with no following token, '--target --foo' (next arg is another flag), or '--target' as the last argument. consumeTargetArg would otherwise silently splice nothing and let root selection degrade.","commonSituations":"User typed '--target' then hit enter before the path; shell quoting dropped an empty value (--target ''); the path was a variable that expanded to empty (TARGET= node ... --target $TARGET); user intended '--target=somepath' form but wrote space-separated with a missing value.","solutions":["Provide a concrete path right after --target: '... --target ./apps/web'.","Use the equals form to avoid ambiguity: '--target=./apps/web'.","If the path comes from a variable, default it first: TARGET=${TARGET:-./apps/web}."],"exampleFix":"# before\nnode live-inject.mjs --target --comment-syntax html\n# after\nnode live-inject.mjs --target ./apps/web --comment-syntax html","handlingStrategy":"validation","validationCode":"const idx = argv.indexOf('--target');\nif (idx !== -1) {\n  const v = argv[idx + 1];\n  if (typeof v !== 'string' || v === '' || v.startsWith('--')) {\n    throw new Error('provide a path: --target ./apps/web');\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pair --target with its value in wrapper scripts, or prefer the --target=PATH form.","Default empty shell variables before expanding them into args.","Validate argv shape in a thin CLI shim before calling the helper."],"tags":["cli","live-roots","argument-parsing","target"],"backgroundTag":null,"analyzedSha":"d14711ae3d1a1dd62dee61a358d27f107c51ccd0","analyzedAt":"2026-08-13T00:52:25.771Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}