santifer/career-ops · error · Error
decision must be one of: ${[...DECISIONS].join(', ')}
Error message
decision must be one of: ${[...DECISIONS].join(', ')} What it means
Validation in `writeReuseDecision`: the `decision` field must be a member of `DECISIONS` (defined as the set `['reuse', 'reuse-with-edits', 'regenerate']`). The decision is persisted into an auditable record beside the application artifacts, so an unrecognized value would make the audit log unreadable. The check fires before any directory or file write.
Source
Thrown at application-artifacts.mjs:86
join(paths.root, 'jd'),
join(paths.root, 'cv', 'source'),
paths.cv.tailored.root,
join(paths.root, 'decision'),
]) mkdirSync(directory, { recursive: true });
return paths;
}
/** Write an auditable CV reuse decision beside the application artifacts. */
export function writeReuseDecision(paths, {
decision,
score = null,
sourceCv = null,
currentJd = null,
previousSource = null,
changedSections = [],
userOverride = false,
}) {
if (!DECISIONS.has(decision)) throw new Error(`decision must be one of: ${[...DECISIONS].join(', ')}`);
if (!Array.isArray(changedSections)) throw new Error('changedSections must be an array');
ensureApplicationArtifactDirs(paths);
const record = {
schema_version: 1,
decision,
score,
source_cv: sourceCv,
current_jd: currentJd,
previous_source: previousSource,
changed_sections: changedSections,
user_override: Boolean(userOverride),
recorded_at: new Date().toISOString(),
};
writeFileSync(paths.decision.reuse, `${JSON.stringify(record, null, 2)}\n`);
return record;
}
function usage() {View on GitHub (pinned to 9b17a8ac97)
Solutions
- Use exactly one of: `reuse`, `reuse-with-edits`, `regenerate` (lowercase, exact spelling).
- Map your caller's vocabulary onto these three before invoking `writeReuseDecision`.
- If you need a new decision type, extend `DECISIONS` deliberately and update the schema_version + docs.
- Guard upstream: `if (!['reuse','reuse-with-edits','regenerate'].includes(d)) throw ...`.
- Add a unit test enumerating accepted and rejected values.
Example fix
// before
writeReuseDecision(paths, { decision: 'edited', score: 0.8 }); // throws
// after
writeReuseDecision(paths, { decision: 'reuse-with-edits', score: 0.8, changedSections: ['summary'] }); Defensive patterns
Strategy: validation
Validate before calling
const DECISIONS = new Set(['reuse', 'reuse-with-edits', 'regenerate']);
function validDecision(d) {
if (!DECISIONS.has(d)) throw new Error(`decision must be one of: ${[...DECISIONS].join(', ')}`);
return d;
} Type guard
function isReuseDecision(d) {
return ['reuse', 'reuse-with-edits', 'regenerate'].includes(d);
} Prevention
- Map caller vocabulary onto the three accepted values before invoking.
- Treat the decision set as a schema enum; extend it deliberately with a schema_version bump.
- Validate in tests covering all three plus one invalid value.
- Lowercase exact spelling — 'REUSE' is rejected.
When it happens
Trigger: Passing `decision: 'edit'`, `'modified'`, `'new'`, `'custom'`, `'REUSE'` (case-sensitive — must be exactly lowercase as defined), `undefined`, or `null`.
Common situations: Caller uses its own status vocabulary; agent invents a decision label; case mismatch (capital first letter); migrating from a system with different reuse semantics; passing a user-typed string straight through.
Related errors
- Application answer state must be one of: ${[...VALID_STATES]
- reportNum must be a numeric report number
- version must be a positive integer
- payload must include at least one of: cv, articleDigest
- payload.cv requires { section, entry }
AI-assisted analysis of santifer/career-ops@9b17a8ac97 (2026-08-13).
Data as JSON: /api/errors/dbe5d326aa9a3d44.
Report an issue: GitHub.