{"record":{"id":"aeccb7d4c798d70e","repo":"pbakaus/impeccable","slug":"target-requires-a-path-value-use-target-path","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/f88b2837a7d7c3182e46307bbbb091a1ed547571/skill/scripts/live/roots.mjs#L433-L469","documentation":"consumeTargetArg() (skill/scripts/live/roots.mjs) strips '--target <path>' from a live helper's argv (mutating it via splice) and returns the value so the helper operates on an explicit app root. In the separate-token form, it throws — unconditionally, there is no non-strict mode — when '--target' is the last token, or the next token is not a usable string (empty, or itself starting with '--'). The guard is deliberate: these helpers mutate session state, and a valueless --target must not degrade into implicit 'most recent app' root selection.","triggerScenarios":"Invoking a live helper (e.g. live-commit-manual-edits.mjs) with '--target' as the final argument; '--target --verbose' where the intended value was forgotten and the next token parses as a flag; '--target \"\"' from an unset or empty shell variable.","commonSituations":"Shell scripts appending --target conditionally while the value lands in a different branch; quoting/continuation-line mistakes splitting flag from value; variable empty due to a typo in its name.","solutions":["Pass the value attached to the flag: --target /path/to/app or --target=/path/to/app","Guard optional targeting in scripts: only add the pair when non-empty — [[ -n \"$TARGET\" ]] && set -- --target \"$TARGET\" \"$@\"","Drop --target entirely when operating on the implicitly selected root is acceptable"],"exampleFix":"# before\nnode live-commit-manual-edits.mjs --target\n\n# after\nnode live-commit-manual-edits.mjs --target /path/to/app","handlingStrategy":"validation","validationCode":"function validateTargetArg(argv) {\n  const i = argv.indexOf('--target');\n  if (i === -1) return true;\n  const value = argv[i + 1];\n  return typeof value === 'string' && value !== '' && !value.startsWith('--');\n}\n\nif (!validateTargetArg(process.argv)) {\n  console.error('--target requires a path value (use --target <path> or --target=<path>)');\n  process.exit(2);\n}","typeGuard":null,"tryCatchPattern":"let target;\ntry {\n  target = consumeTargetArg(process.argv);\n} catch (err) {\n  if (err?.message?.includes('--target requires a path value')) {\n    printUsageAndExit(2);\n  }\n  throw err;\n}","preventionTips":["Emit flag and value as an inseparable pair in wrappers: args.push('--target', target) only after the non-empty check","Shell guards: [[ -n \"$TARGET\" ]] && set -- --target \"$TARGET\" \"$@\"","Remember this helper throws always (no lenient mode) because a valueless --target must not fall back to implicit root selection"],"tags":["cli","arguments","target-path","live"],"backgroundTag":"missing-cli-argument-value","analyzedSha":"f88b2837a7d7c3182e46307bbbb091a1ed547571","analyzedAt":"2026-08-18T04:58:36.608Z","contentChangedAt":"2026-08-18T04:58:36.608Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}