santifer/career-ops · error · Error
payload.articleDigest requires a non-empty dedupKey (used…
Error message
payload.articleDigest requires a non-empty dedupKey (used for dedup/idempotency)
What it means
add-entry.mjs throws this when a caller passes payload.articleDigest but omits dedupKey or supplies one that normalizes to empty. dedupKey is the identity used by articleDigestHasEntry to detect duplicate entries and make the write idempotent, so the library refuses to proceed without it. It is an input-contract violation, not a filesystem problem.
Solutions
- Set a non-empty, stable dedupKey in the payload (e.g. a slug of the article title, the source URL, or a project+metric key) so repeat runs are treated as duplicates instead of re-added.
- Verify the value feeding dedupKey is defined and non-blank before calling applyAdd (log or assert it).
- If you only wanted to append a CV entry, check you did not accidentally nest it under payload.articleDigest; that branch has different requirements.
Example fix
// before
applyAdd({ payload: { articleDigest: { entry } } });
// after
const dedupKey = slugify(article.title);
if (!dedupKey) throw new Error('cannot derive dedupKey from article title');
applyAdd({ payload: { articleDigest: { dedupKey, entry } } }); Defensive patterns
Strategy: validation
Validate before calling
function hasDedupKey(payload) {
return Boolean(payload?.articleDigest?.dedupKey && String(payload.articleDigest.dedupKey).trim());
}
if (!hasDedupKey(payload)) throw new Error('articleDigest payload needs a non-empty dedupKey'); Type guard
function hasArticleDigestPayload(p) {
return typeof p?.articleDigest?.dedupKey === 'string' && p.articleDigest.dedupKey.trim() !== '' && p.articleDigest.entry != null;
} Prevention
- Derive dedupKey from a stable source field (URL or slugified title) and assert it before building the payload.
- Write a unit test that constructs every payload variant your scripts produce and asserts hasDedupKey.
- Never pass user-typed raw strings as dedupKey without trimming and checking for emptiness.
When it happens
Trigger: Calling applyAdd (or the add-entry CLI path) with payload.articleDigest = { entry } but no dedupKey, with dedupKey: undefined/null/'', or with a dedupKey that is only whitespace after normalization. Often happens when building the payload programmatically and the field that should feed dedupKey (e.g. a slug or URL) is undefined.
Common situations: Scripting bulk imports of portfolio proof points into article-digest.md where some source objects lack an identifier field; renaming a payload field (id -> dedupKey) and forgetting to update construction sites; template literals interpolating an empty variable into the key.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Application answer state must be one of
- payload.cv requires a non-empty dedupKey (used for…
- 4dayweek: invalid URL
- 4dayweek: URL must use HTTPS
- a 40-hex commit --sha is required
AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16).
Data as JSON: /api/errors/8b5fb02b64f2dc2e.
Report an issue: GitHub.
Appendix: source
Thrown at add-entry.mjs:196
if (payload.cv) {
const { section, dedupKey, entry } = payload.cv;
if (!section || !entry) throw new Error('payload.cv requires { section, entry }');
// dedupKey is what makes the insert idempotent — refuse to add without one
// rather than silently allowing duplicate re-runs.
if (!normalizeKey(dedupKey)) throw new Error('payload.cv requires a non-empty dedupKey (used for dedup/idempotency)');
if (cvText === null) throw new Error(`cv.md not found — cannot add to a CV that does not exist`);
if (cvHasEntry(cvText, section, dedupKey)) {
result.cv = { status: 'duplicate', section };
} else {
cv = insertIntoCvSection(cvText, section, entry);
result.cv = { status: 'added', section };
}
}
if (payload.articleDigest) {
const { dedupKey, entry } = payload.articleDigest;
if (!entry) throw new Error('payload.articleDigest requires { entry }');
if (!normalizeKey(dedupKey)) throw new Error('payload.articleDigest requires a non-empty dedupKey (used for dedup/idempotency)');
// article-digest.md is optional; create it from a header when missing.
const current = articleText === null
? '# Article Digest -- Proof Points\n\nCompact proof points from portfolio projects. Read by career-ops at evaluation time.\n'
: articleText;
if (articleDigestHasEntry(current, dedupKey)) {
result.articleDigest = { status: 'duplicate' };
articleDigest = articleText;
} else {
articleDigest = appendArticleDigest(current, entry);
result.articleDigest = { status: articleText === null ? 'created' : 'added' };
}
}
return { cv, articleDigest, result };
}
async function readStdin() {
const chunks = [];View on GitHub (pinned to aac998c7ed)