{"record":{"id":"10ef14826c3503eb","repo":"santifer/career-ops","slug":"name-is-required","errorCode":null,"errorMessage":"--${name} is required","messagePattern":"--(.+?) is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"assessment-log.mjs","lineNumber":126,"sourceCode":"  }\n  return {\n    assessments: rows,\n    aggregates: { byPlatform },\n    quality: {\n      total: rows.length,\n      staleFlagged,\n      withoutScore: rows.filter(r => r.score === null).length,\n      withoutThreshold: rows.filter(r => r.threshold === null).length,\n      malformedLines: malformed,\n    },\n  };\n}\n\n// --- Append (`add` subcommand) ---\nexport function buildRow(fields, today) {\n  const req = (name) => {\n    const v = String(fields[name] ?? '').trim();\n    if (!v) throw new Error(`--${name} is required`);\n    if (v.includes('\\t') || v.includes('\\n')) throw new Error(`--${name} must not contain tabs or newlines`);\n    return v;\n  };\n  const opt = (name) => {\n    const v = String(fields[name] ?? '').trim();\n    if (v.includes('\\t') || v.includes('\\n')) throw new Error(`--${name} must not contain tabs or newlines`);\n    return v || '-';\n  };\n  const optPct = (name) => {\n    const v = String(fields[name] ?? '').trim();\n    if (!v) return '-';\n    if (parsePct(v) === null) throw new Error(`--${name} must be a percentage (e.g. 70 or 70%), got \"${v}\"`);\n    return v;\n  };\n  return [\n    today, req('company'), opt('report'), req('platform'), req('subject'),\n    optPct('threshold'), optPct('score'), opt('stale') === '-' ? '' : opt('stale'),\n  ].join('\\t');","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/assessment-log.mjs#L108-L144","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nnode assessment-log.mjs add --platform leetcode --subject \"system design\"\n// Error: --company is required\n// after\nnode assessment-log.mjs add --company \"Acme GmbH\" --platform leetcode --subject \"system design\"","handlingStrategy":"validation","validationCode":"const REQUIRED = ['company', 'platform', 'subject'];\nconst missing = REQUIRED.filter((n) => !String(fields[n] ?? '').trim());\nif (missing.length) throw new Error(`missing required flags: --${missing.join(', --')}`);","typeGuard":"function hasRequired(fields) {\n  return ['company', 'platform', 'subject'].every((n) => String(fields[n] ?? '').trim() !== '');\n}","tryCatchPattern":"try {\n  const row = buildRow(fields, today);\n} catch (err) {\n  if (/^--[\\w-]+ is required$/.test(err.message)) {\n    const flag = err.message.split(' ')[0];\n    console.error(`Add the ${flag} flag and retry.`);\n  } else throw err;\n}","preventionTips":["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."],"tags":["cli","validation","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"aac998c7ed7248ea853b720ceeb1fdbeb322fc5d","analyzedAt":"2026-09-16T06:35:29.214Z","contentChangedAt":"2026-09-16T06:35:29.214Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}