{"record":{"id":"ba7c9195e19a484e","repo":"pbakaus/impeccable","slug":"target-value-missing","errorCode":"TARGET_VALUE_MISSING","errorMessage":"--target requires a path value.","messagePattern":"--target requires a path value\\.","errorType":"validation","errorClass":"TargetArgError","httpStatus":null,"severity":"error","filePath":"plugin/skills/impeccable/scripts/lib/target-args.mjs","lineNumber":21,"sourceCode":"    super(message);\n    this.name = 'TargetArgError';\n    this.code = code;\n  }\n}\n\nexport function parseTargetPath(args = [], { strict = false } = {}) {\n  let targetPath = null;\n  for (let i = 0; i < args.length; i++) {\n    const arg = String(args[i]);\n    if (arg === '--target' || arg === '-t') {\n      const next = args[i + 1];\n      if (next && !String(next).startsWith('-')) {\n        targetPath = String(next);\n        i++;\n        continue;\n      }\n      if (strict) {\n        throw new TargetArgError('--target requires a path value.', 'TARGET_VALUE_MISSING');\n      }\n      continue;\n    }\n    if (arg.startsWith('--target=')) {\n      const value = arg.slice('--target='.length);\n      if (value) {\n        targetPath = value;\n        continue;\n      }\n      if (strict) {\n        throw new TargetArgError('--target requires a path value.', 'TARGET_VALUE_MISSING');\n      }\n    }\n  }\n  return targetPath;\n}\n\nexport function parseTargetOptions(args = [], options = {}) {","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/pbakaus/impeccable/blob/d14711ae3d1a1dd62dee61a358d27f107c51ccd0/plugin/skills/impeccable/scripts/lib/target-args.mjs#L3-L39","documentation":"Thrown by parseTargetPath() in strict mode when --target or -t is the last token, or its following token starts with '-' (i.e. looks like another flag). The parser refuses to consume a flag-shaped token as a path, so '--target --port 3000' is treated as a missing value rather than path='--port'. Only fires when options.strict is true; in non-strict the missing value is silently ignored and targetPath stays null.","triggerScenarios":"Calling parseTargetOptions(['--target'], { strict: true }); '--target -t' (next is a flag); '--target' as the final argv element; '-t' followed by nothing. Common in CLI wrappers that pass { strict: true } to fail fast on malformed invocations.","commonSituations":"User forgets the path after --target; shell quoting drops an empty argument; a script concatenates flags and accidentally orders --target before another flag; using '-t' shorthand with no value. The TargetArgError exposes .code = 'TARGET_VALUE_MISSING' for programmatic handling.","solutions":["Supply a concrete path token after --target/-t that does not start with '-' (e.g. --target src/index.html).","If the value legitimately could be flag-adjacent, use the '--target=PATH' equals form instead, which is parsed separately and allows any value.","Catch TargetArgError and check err.code === 'TARGET_VALUE_MISSING' to print a usage hint and exit non-zero instead of crashing.","If silent tolerance is desired, call without { strict: true } and check the returned targetPath for null afterwards."],"exampleFix":"// before\nconst { targetPath } = parseTargetOptions(args, { strict: true });\n\n// after\ndefaults to non-strict:\nconst { targetPath } = parseTargetOptions(args);\nif (!targetPath) { console.error('--target requires a path'); process.exit(2); }\n\nor keep strict and handle:\ntry { parseTargetOptions(args, { strict: true }); }\ncatch (err) { if (err.code === 'TARGET_VALUE_MISSING') { printUsage(); process.exit(2); } throw err; }","handlingStrategy":"validation","validationCode":"import { parseTargetPath } from './lib/target-args.mjs';\n// Pre-check in non-strict mode to avoid the throw.\nconst targetPath = parseTargetPath(args); // strict defaults to false\nif (!targetPath) {\n  console.error('--target requires a path value.');\n  process.exit(2);\n}","typeGuard":null,"tryCatchPattern":"import { parseTargetOptions } from './lib/target-args.mjs';\ntry {\n  const { targetPath } = parseTargetOptions(args, { strict: true });\n} catch (err) {\n  if (err.code === 'TARGET_VALUE_MISSING') {\n    printUsage();\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Prefer the '--target=PATH' equals form when scripting — it sidesteps flag-adjacency ambiguity.","Validate interpolated argv values before building the array so an empty variable doesn't emit a bare --target.","Match on err.code (TARGET_VALUE_MISSING), not err.message, to stay stable across rewordings."],"tags":["cli","argv-parsing","target-args"],"backgroundTag":null,"analyzedSha":"d14711ae3d1a1dd62dee61a358d27f107c51ccd0","analyzedAt":"2026-08-13T00:52:25.771Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}