santifer/career-ops · error

getonbrd: `categories` is empty — omit it to use the…

Error message

getonbrd: `categories` is empty — omit it to use the "programming" default

What it means

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.

Solutions

  1. Remove the categories field entirely so the DEFAULT_CATEGORY ('programming') applies.
  2. Or populate the list with at least one valid slug.
  3. If 'search all categories' is the goal, that is not supported — omit categories and rely on other filters instead.
  4. Fix the template/script that emitted an empty array.

Example fix

# before
categories: []
# after
# (field omitted — defaults to "programming")
Defensive patterns

Strategy: validation

Validate before calling

if (Array.isArray(cfg.categories) && cfg.categories.length === 0) delete cfg.categories; // fall back to default

Type guard

const hasCategories = (c) => Array.isArray(c.categories) && c.categories.length > 0;

Try / catch

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; }

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16). Data as JSON: /api/errors/43451d60ab2fad21. Report an issue: GitHub.

Appendix: source

Thrown at providers/getonbrd.mjs:65

 * @returns {string[]}
 */
export function resolveCategories(entry) {
  const raw = entry?.categories !== undefined ? entry.categories : entry?.category;
  if (raw === undefined || raw === null) return [DEFAULT_CATEGORY];

  const list = Array.isArray(raw) ? raw : [raw];
  const out = [];
  for (const c of list) {
    if (typeof c !== 'string' || !CATEGORY_SLUG_RE.test(c.trim())) {
      throw new Error(
        `getonbrd: invalid category ${JSON.stringify(c)} — expected a slug like "programming" or "machine-learning-ai"`,
      );
    }
    const slug = c.trim();
    if (!out.includes(slug)) out.push(slug);
  }
  if (!out.length) {
    throw new Error('getonbrd: `categories` is empty — omit it to use the "programming" default');
  }
  if (out.length > MAX_CATEGORIES) {
    throw new Error(
      `getonbrd: ${out.length} categories configured — cap is ${MAX_CATEGORIES} (each one costs up to max_pages requests)`,
    );
  }
  return out;
}

/** @param {string} url */
function assertGetonbrdUrl(url) {
  let parsed;
  try {
    parsed = new URL(url);
  } catch {
    throw new Error(`getonbrd: invalid URL: ${url}`);
  }
  if (parsed.protocol !== 'https:') throw new Error(`getonbrd: URL must use HTTPS: ${url}`);

View on GitHub (pinned to aac998c7ed)