santifer/career-ops · error · Error

-- is required

Error message

--${name} is required

What it means

assessment-log.mjs's buildRow() builds a TSV row for the `add` subcommand. The req() helper reads the named field, trims it, and throws when the resulting value is empty. This guards the append-only assessments.tsv file against rows missing mandatory fields (company, platform, subject), which would corrupt the structured log that assessment-log.mjs's --summary output folds over.

Solutions

  1. Re-run the `add` command supplying the missing flag (check the message for the exact --name reported, e.g. --company, --platform, or --subject).
  2. Check shell quoting so the flag's value is not an empty string (e.g. --company "Acme GmbH" for names with spaces).
  3. If calling buildRow() programmatically, ensure every required key exists with a non-empty trimmed value before invoking it.
  4. If the value genuinely does not exist, that field is mandatory — do not bypass; either obtain it or skip logging this assessment.

Example fix

// before
node assessment-log.mjs add --platform leetcode --subject "system design"
// Error: --company is required
// after
node assessment-log.mjs add --company "Acme GmbH" --platform leetcode --subject "system design"
Defensive patterns

Strategy: validation

Validate before calling

const REQUIRED = ['company', 'platform', 'subject'];
const missing = REQUIRED.filter((n) => !String(fields[n] ?? '').trim());
if (missing.length) throw new Error(`missing required flags: --${missing.join(', --')}`);

Type guard

function hasRequired(fields) {
  return ['company', 'platform', 'subject'].every((n) => String(fields[n] ?? '').trim() !== '');
}

Try / catch

try {
  const row = buildRow(fields, today);
} catch (err) {
  if (/^--[\w-]+ is required$/.test(err.message)) {
    const flag = err.message.split(' ')[0];
    console.error(`Add the ${flag} flag and retry.`);
  } else throw err;
}

Prevention

When it happens

Trigger: Calling buildRow() (via `node assessment-log.mjs add ...`) without a value for a required flag: `--company`, `--platform`, or `--subject` supplied as empty string, whitespace-only, omitted, or explicitly null/undefined in the fields object. Also `String(fields[name] ?? '')` means fields['company']=null triggers it.

Common situations: Typing `node assessment-log.mjs add --platform codewars --subject regex` and forgetting `--company`; shell-quoting mistakes producing `--company ""`; a wrapper script building the arg map from env vars that are unset, yielding empty strings; misspelling a flag so its value never lands in the fields object under the expected name.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at assessment-log.mjs:126

  }
  return {
    assessments: rows,
    aggregates: { byPlatform },
    quality: {
      total: rows.length,
      staleFlagged,
      withoutScore: rows.filter(r => r.score === null).length,
      withoutThreshold: rows.filter(r => r.threshold === null).length,
      malformedLines: malformed,
    },
  };
}

// --- Append (`add` subcommand) ---
export function buildRow(fields, today) {
  const req = (name) => {
    const v = String(fields[name] ?? '').trim();
    if (!v) throw new Error(`--${name} is required`);
    if (v.includes('\t') || v.includes('\n')) throw new Error(`--${name} must not contain tabs or newlines`);
    return v;
  };
  const opt = (name) => {
    const v = String(fields[name] ?? '').trim();
    if (v.includes('\t') || v.includes('\n')) throw new Error(`--${name} must not contain tabs or newlines`);
    return v || '-';
  };
  const optPct = (name) => {
    const v = String(fields[name] ?? '').trim();
    if (!v) return '-';
    if (parsePct(v) === null) throw new Error(`--${name} must be a percentage (e.g. 70 or 70%), got "${v}"`);
    return v;
  };
  return [
    today, req('company'), opt('report'), req('platform'), req('subject'),
    optPct('threshold'), optPct('score'), opt('stale') === '-' ? '' : opt('stale'),
  ].join('\t');

View on GitHub (pinned to aac998c7ed)