{"record":{"id":"43451d60ab2fad21","repo":"santifer/career-ops","slug":"getonbrd-categories-is-empty-omit-it-to-use-t","errorCode":null,"errorMessage":"getonbrd: `categories` is empty — omit it to use the \"programming\" default","messagePattern":"getonbrd: `categories` is empty — omit it to use the \"programming\" default","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"providers/getonbrd.mjs","lineNumber":65,"sourceCode":" * @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 */\nfunction assertGetonbrdUrl(url) {\n  let parsed;\n  try {\n    parsed = new URL(url);\n  } catch {\n    throw new Error(`getonbrd: invalid URL: ${url}`);\n  }\n  if (parsed.protocol !== 'https:') throw new Error(`getonbrd: URL must use HTTPS: ${url}`);","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/providers/getonbrd.mjs#L47-L83","documentation":"After filtering and deduplication, resolveCategories requires at least one category; an empty list cannot form a valid request. The error tells the caller to simply omit the categories field, which falls back to the 'programming' default category.","triggerScenarios":"Configuring categories: [] explicitly; an entry whose categories value is an empty YAML list, e.g. produced by a templating step that had no categories selected (non-matching entries throw error 257 first, so this fires only for a valid-typed but empty list).","commonSituations":"Templating/CI generating portals.yml emitted categories: [] when no categories were chosen; a user clearing the field to mean 'everything' without realizing omission is the correct way to get the default.","solutions":["Remove the categories field entirely so the DEFAULT_CATEGORY ('programming') applies.","Or populate the list with at least one valid slug.","If 'search all categories' is the goal, that is not supported — omit categories and rely on other filters instead.","Fix the template/script that emitted an empty array."],"exampleFix":"# before\ncategories: []\n# after\n# (field omitted — defaults to \"programming\")","handlingStrategy":"validation","validationCode":"if (Array.isArray(cfg.categories) && cfg.categories.length === 0) delete cfg.categories; // fall back to default","typeGuard":"const hasCategories = (c) => Array.isArray(c.categories) && c.categories.length > 0;","tryCatchPattern":"try { resolveCategories(entry); } catch (e) { if (e.message.includes('`categories` is empty')) console.error('Omit categories to use the default, or supply at least one slug'); throw e; }","preventionTips":["Delete the field rather than leaving it empty — omission IS the default","Guard template generators against emitting empty arrays","Document that 'all categories' is expressed by omitting the field","Validate config at startup so the mistake surfaces before scans"],"tags":["config","validation","empty"],"backgroundTag":"empty-required-field","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"}