{"record":{"id":"7634df7bf942ea8d","repo":"santifer/career-ops","slug":"getonbrd-invalid-category-json-stringify-c","errorCode":null,"errorMessage":"getonbrd: invalid category ${JSON.stringify(c)} — expected a slug like \"programming\" or \"machine-learning-ai\"","messagePattern":"getonbrd: invalid category (.+?) — expected a slug like \"programming\" or \"machine-learning-ai\"","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"providers/getonbrd.mjs","lineNumber":57,"sourceCode":"/**\n * Resolve the categories to scan, in config order, deduped.\n *\n * `categories:` (array) wins over `category:` (string); neither → the\n * `programming` default, which keeps pre-existing entries byte-identical.\n * Exported for tests.\n *\n * @param {any} entry\n * @returns {string[]}\n */\nexport function resolveCategories(entry) {\n  const raw = entry?.categories !== undefined ? entry.categories : entry?.category;\n  if (raw === undefined || raw === null) return [DEFAULT_CATEGORY];\n\n  const list = Array.isArray(raw) ? raw : [raw];\n  const out = [];\n  for (const c of list) {\n    if (typeof c !== 'string' || !CATEGORY_SLUG_RE.test(c.trim())) {\n      throw new Error(\n        `getonbrd: invalid category ${JSON.stringify(c)} — expected a slug like \"programming\" or \"machine-learning-ai\"`,\n      );\n    }\n    const slug = c.trim();\n    if (!out.includes(slug)) out.push(slug);\n  }\n  if (!out.length) {\n    throw new Error('getonbrd: `categories` is empty — omit it to use the \"programming\" default');\n  }\n  if (out.length > MAX_CATEGORIES) {\n    throw new Error(\n      `getonbrd: ${out.length} categories configured — cap is ${MAX_CATEGORIES} (each one costs up to max_pages requests)`,\n    );\n  }\n  return out;\n}\n\n/** @param {string} url */","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/providers/getonbrd.mjs#L39-L75","documentation":"resolveCategories validates every configured Getonboard category against CATEGORY_SLUG_RE (lowercase kebab-case slugs). Values that are not strings or do not match the slug pattern are rejected with this message showing the offending value JSON-encoded and an example of valid slugs.","triggerScenarios":"Configuring categories: ['Machine Learning'] (spaces/capitals), ['programming', 42] (non-string member), or 'Software Development' — anything failing CATEGORY_SLUG_RE — in portals.yml or wherever the entry's categories field is set.","commonSituations":"Writing human-readable category names instead of the portal's URL slugs; YAML parsing a category as a number or boolean (e.g. an unquoted value); copy-pasting a display label from the Getonboard UI instead of its slug.","solutions":["Convert each category to its Getonboard slug: lowercase, hyphen-separated (e.g. 'machine-learning-ai').","Quote values in YAML that could parse as non-strings (numbers, booleans).","Browse getonbrd.com category URLs to confirm the exact slug spelling before configuring it.","Start from the documented defaults ('programming', 'machine-learning-ai') and only add slugs you've verified."],"exampleFix":"// before\ncategories: [\"Data Science\", \"Programming\"]\n// after\ncategories: [\"data-science\", \"programming\"]","handlingStrategy":"validation","validationCode":"const CATEGORY_SLUG_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/;\nconst bad = (cfg.categories || []).filter(c => typeof c !== 'string' || !CATEGORY_SLUG_RE.test(c.trim()));\nif (bad.length) throw new Error(`Non-slug categories: ${bad.join(', ')}`);","typeGuard":"const isCategorySlug = (c) => typeof c === 'string' && /^[a-z0-9]+(-[a-z0-9]+)*$/.test(c.trim());","tryCatchPattern":"try { resolveCategories(entry); } catch (e) { if (e.message.includes('invalid category')) console.error('Convert display names to slugs and quote YAML values:', e.message); throw e; }","preventionTips":["Use portal URL slugs, never UI display labels","Quote YAML scalar values to avoid numeric/boolean coercion","Keep a vetted list of known-good category slugs in the template","Lint config at load time with the same regex the provider uses"],"tags":["validation","config","slug"],"backgroundTag":"invalid-argument-format","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"}