{"record":{"id":"f7d30942f87dbb87","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":"Error","httpStatus":null,"severity":"error","filePath":"plugin/skills/impeccable/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/plugin/skills/impeccable/scripts/live/roots.mjs#L433-L469","documentation":"Thrown by consumeTargetArg when the live boot sees `--target` as a bare flag with no following path argument (the next token is missing, empty, or itself starts with `--`). The guard exists so a malformed target cannot degrade into implicit 'most recent app' selection, which would silently mutate the wrong app's session state.","triggerScenarios":"Invoking a live helper with `--target` at the end of argv, `--target --port 4321`, or `--target \"\"`. The throw fires from the space-separated form branch before argv mutation.","commonSituations":"Shell quoting mistake, a typo where another flag follows --target, or a script that conditionally appends --target but forgets the value.","solutions":["Provide the path right after: `--target ./apps/web` or use the equals form `--target=./apps/web`.","Check your wrapper script for cases where the target path variable is empty before appending --target.","Run the helper without --target to fall back to implicit root resolution if multi-app disambiguation is not needed."],"exampleFix":"# before\nnode helper.mjs --target\n\n# after\nnode helper.mjs --target ./apps/web","handlingStrategy":"validation","validationCode":"function validateTargetArg(argv) {\n  const idx = argv.indexOf('--target');\n  if (idx === -1) return null;\n  const value = argv[idx + 1];\n  if (typeof value !== 'string' || value === '' || value.startsWith('--')) {\n    throw new Error('--target needs a path');\n  }\n  return value;\n}","typeGuard":"function isValidTargetValue(value) {\n  return typeof value === 'string' && value.length > 0 && !value.startsWith('--');\n}","tryCatchPattern":"try {\n  consumeTargetArg(process.argv);\n} catch (err) {\n  console.error(err.message);\n  process.exit(1);\n}","preventionTips":["Always pair --target with its path in wrapper scripts, never append it conditionally.","Prefer the --target=path form to avoid ambiguity with following flags.","Test CLI wrappers with an unset target variable to confirm they degrade safely."],"tags":["cli","argv","impeccable-live","validation"],"backgroundTag":null,"analyzedSha":"d14711ae3d1a1dd62dee61a358d27f107c51ccd0","analyzedAt":"2026-08-13T00:52:25.771Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}