pbakaus/impeccable · error · TargetArgError
TARGET_VALUE_MISSING
TARGET_VALUE_MISSING
Error message
--target requires a path value.
What it means
Thrown by parseTargetPath in strict mode when --target/-t is followed by no value, or by another dash-prefixed token, or when --target= has an empty value. It is a TargetArgError carrying code TARGET_VALUE_MISSING (and name 'TargetArgError') so callers can distinguish it programmatically. In non-strict mode the same input is skipped silently and null is returned.
Solutions
- Give --target a value: `--target src/pages/index.astro`.
- Use the attached form `--target=src/pages/index.astro`, which cannot be separated from its value.
- Note that a value beginning with '-' (rare relative path) will be treated as a flag; prefix it as ./-weird or use the = form.
- If invoking parseTargetPath programmatically in strict mode, catch TargetArgError and check err.code === 'TARGET_VALUE_MISSING'.
Example fix
# before node script.mjs --scope page --target # after node script.mjs --scope page --target src/pages/index.astro node script.mjs --scope page --target=src/pages/index.astro
Defensive patterns
Strategy: type-guard
Validate before calling
function hasTargetValue(args) {
for (let i = 0; i < args.length; i++) {
const a = String(args[i]);
if ((a === '--target' || a === '-t') && !(args[i + 1] && !String(args[i + 1]).startsWith('-'))) return false;
if (a.startsWith('--target=') && !a.slice('--target='.length)) return false;
}
return true;
}
if (!hasTargetValue(argv)) { console.error('--target needs a value'); process.exit(2); } Type guard
class TargetArgError extends Error {}
function isTargetValueMissing(err) {
return err instanceof TargetArgError && err.code === 'TARGET_VALUE_MISSING';
} Try / catch
import { parseTargetPath } from './lib/target-args.mjs';
try {
const targetPath = parseTargetPath(argv, { strict: true });
} catch (err) {
if (err.name === 'TargetArgError' && err.code === 'TARGET_VALUE_MISSING') {
console.error('usage: --target <path> (or --target=<path>)');
process.exit(2);
}
throw err;
} Prevention
- Prefer the attached form --target=<path> in generated command lines — value and flag cannot separate.
- Check that variables interpolated after --target are non-empty before spawning.
- Catch TargetArgError by code when running parseTargetPath strict from library code.
When it happens
Trigger: `--target` as the last argument; `--target --mode local` (next token starts with '-', treated as a flag not a value); `--target=` with nothing after the equals; non-strict callers getting null and then failing downstream with a less specific error.
Common situations: Scripts building command lines from optional variables that are empty; flag reordering that puts a value-taking flag adjacent to another flag; users assuming --target defaults to the current directory.
Related errors
- requires a glob
- Aborted.
- ambiguous snapshot slug; use an explicit ./path or remove…
- Authentication failed. The server token may have changed.
- Available commands
AI-assisted analysis of pbakaus/impeccable@f88b2837a7 (2026-08-18).
Data as JSON: /api/errors/840e80570b9c6c15.
Report an issue: GitHub.
Appendix: source
Thrown at skill/scripts/lib/target-args.mjs:21
super(message);
this.name = 'TargetArgError';
this.code = code;
}
}
export function parseTargetPath(args = [], { strict = false } = {}) {
let targetPath = null;
for (let i = 0; i < args.length; i++) {
const arg = String(args[i]);
if (arg === '--target' || arg === '-t') {
const next = args[i + 1];
if (next && !String(next).startsWith('-')) {
targetPath = String(next);
i++;
continue;
}
if (strict) {
throw new TargetArgError('--target requires a path value.', 'TARGET_VALUE_MISSING');
}
continue;
}
if (arg.startsWith('--target=')) {
const value = arg.slice('--target='.length);
if (value) {
targetPath = value;
continue;
}
if (strict) {
throw new TargetArgError('--target requires a path value.', 'TARGET_VALUE_MISSING');
}
}
}
return targetPath;
}
export function parseTargetOptions(args = [], options = {}) {View on GitHub (pinned to f88b2837a7)