santifer/career-ops · error · Error
--${name} is required
Error message
--${name} is required What it means
Validation in the `req` helper inside `buildRow` (assessment-log.mjs `add` subcommand). The required fields — `company`, `platform`, `subject` — must each be present and non-empty (after trim). Empty/missing values throw `--<name> is required` so the TSV row is never written with a blank mandatory column.
Source
Thrown at assessment-log.mjs:113
}
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 9b17a8ac97)
Solutions
- Always supply `--company`, `--platform`, and `--subject` with non-empty values when running `add`.
- Run `node assessment-log.mjs add --help` (or read usage) to see required vs optional fields.
- Validate in your caller before invoking: `['company','platform','subject'].forEach(k => { if (!fields[k]?.trim()) throw ... })`.
- Generate the command only after all three values are confirmed non-empty.
- Add a test asserting the missing-field rejection.
Example fix
// before node assessment-log.mjs add --platform leetcode --subject arrays // after node assessment-log.mjs add --company acme --platform leetcode --subject arrays --threshold 70 --score 85
Defensive patterns
Strategy: validation
Validate before calling
const REQUIRED = ['company', 'platform', 'subject'];
function ensureRequired(fields) {
for (const k of REQUIRED) {
if (!String(fields[k] ?? '').trim()) throw new Error(`--${k} is required`);
}
} Type guard
function hasRequiredAssessmentFields(f) {
return ['company', 'platform', 'subject'].every(k =>
typeof f[k] === 'string' && f[k].trim() !== '');
} Prevention
- Run `add --help` to see which flags are mandatory.
- Build the command only after company/platform/subject are confirmed non-empty.
- Validate the field map before invoking buildRow.
- Test that omitting any one of the three throws.
When it happens
Trigger: Invoking the `add` subcommand without `--company`, `--platform`, or `--subject`; passing `--company ""` or whitespace-only; programmatically calling `buildRow({ company: '', platform: 'leetcode', subject: 'algo' }, today)`.
Common situations: User forgets one of the three mandatory flags; agent generates the command but a field is empty; shell quoting collapses a value to empty; copying a template command and missing a field.
Related errors
- --${name} must not contain tabs or newlines
- --${name} must be a percentage (e.g. 70 or 70%), got "${v}"
- Application answer state must be one of: ${[...VALID_STATES]
- Missing value for ${arg}
- Missing required field: ${context}.${key}
AI-assisted analysis of santifer/career-ops@9b17a8ac97 (2026-08-13).
Data as JSON: /api/errors/10ef14826c3503eb.
Report an issue: GitHub.