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
- Re-run the `add` command supplying the missing flag (check the message for the exact --name reported, e.g. --company, --platform, or --subject).
- Check shell quoting so the flag's value is not an empty string (e.g. --company "Acme GmbH" for names with spaces).
- If calling buildRow() programmatically, ensure every required key exists with a non-empty trimmed value before invoking it.
- 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
- Always pass --company, --platform and --subject on every `add` invocation.
- Quote flag values in the shell to avoid empty-string arguments.
- Wrap the command in a shell alias/script that checks required args before invoking.
- Spell flag names carefully — a misspelled flag is indistinguishable from an omitted one.
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
- Application Answers section has
- --from and --to must both be supplied together (or neither…
- --from ( ) must not be after --to ( ).
- Invalid page budget " ". Use a positive integer.
- --limit must be an integer from 1 to 100
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)