santifer/career-ops · error · Error

outcome-types.mjs: " " is accepted by outcome.mjs but has…

Error message

outcome-types.mjs: "${key}" is accepted by outcome.mjs but has no canonical meaning; add it to ALIASES or CANONICAL_OUTCOMES

What it means

lib/outcome-types.mjs performs a load-time self-check: every key in OUTCOME_MAP (the spellings outcome.mjs accepts) must have a canonical meaning — either being listed in CANONICAL_OUTCOMES or mapped through ALIASES. A key that is accepted but has no canonical classification is a real semantic decision, so the module fails at load instead of letting it surface as 'unknown' wherever the journal is consumed.

Solutions

  1. Add the new key to ALIASES, mapping it to an existing canonical outcome, if it is just a spelling.
  2. Add it to CANONICAL_OUTCOMES if it is a genuinely new outcome type.
  3. Rerun the test suite after editing so the load-time invariant check validates the full map.

Example fix

// before
const OUTCOME_MAP = { ...ALIASES, ...CANONICAL_OUTCOMES.reduce(...), 'turned-down': undefined };
// after
const ALIASES = { ..., 'turned-down': 'rejected' };
Defensive patterns

Strategy: validation

Validate before calling

// CI guard before commit
for (const key of Object.keys(OUTCOME_MAP)) {
  if (!CANONICAL_OUTCOMES.includes(key) && !(key in ALIASES)) {
    throw new Error(`outcome key "${key}" needs a canonical meaning`);
  }
}

Try / catch

try {
  await import('./lib/outcome-types.mjs');
} catch (err) {
  if (err.message.includes('no canonical meaning')) {
    console.error('Add the named key to ALIASES (spelling) or CANONICAL_OUTCOMES (new type).');
  } else throw err;
}

Prevention

When it happens

Trigger: A developer adds a new synonym to OUTCOME_MAP (e.g. 'turned-down') but forgets to add it to ALIASES or CANONICAL_OUTCOMES; the very first import of outcome-types.mjs then throws for that key.

Common situations: Contributing a new outcome spelling to outcome.mjs; rebasing branches where one side added the map entry and the other added the canonical list; copy-editing a key's casing so it no longer matches the alias table.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.


AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16). Data as JSON: /api/errors/81eb2f1ea40ded72. Report an issue: GitHub.

Appendix: source

Thrown at lib/outcome-types.mjs:78

 * result. What stops an omission here is the coverage check below and the drift
 * test, not cleverness.
 */
const ALIASES = {
  stage_reached: 'interview_progress',
  interview: 'interview_progress',
  offer: 'offer_received',
  accepted: 'hired',
  declined: 'offer_declined',
  rejection: 'rejected',
  ghosted: 'no_response',
};

// A synonym added to OUTCOME_MAP without a meaning here is a real decision, not
// a spelling. Fail loudly at load rather than let it read as unknown wherever
// the journal is consumed — which is the failure this module exists to end.
for (const key of Object.keys(OUTCOME_MAP)) {
  if (!CANONICAL_OUTCOMES.includes(key) && !(key in ALIASES)) {
    throw new Error(`outcome-types.mjs: "${key}" is accepted by outcome.mjs but has no canonical meaning; add it to ALIASES or CANONICAL_OUTCOMES`);
  }
}

/**
 * Resolve any accepted spelling to its canonical type.
 *
 * Applies the same normalization `outcome.mjs` applies before writing
 * (lowercase, `-` → `_`), so a hand-edited journal saying `Offer-Declined`
 * still resolves.
 *
 * @param {unknown} raw - A type as written in a journal or typed on the CLI.
 * @returns {string|null} The canonical type, or null when unrecognized.
 */
export function canonicalOutcome(raw) {
  const key = String(raw ?? '').trim().toLowerCase().replace(/-/g, '_');
  if (CANONICAL_OUTCOMES.includes(key)) return key;
  return ALIASES[key] ?? null;
}

View on GitHub (pinned to aac998c7ed)