santifer/career-ops · error

arbeitnow: untrusted hostname

Error message

arbeitnow: untrusted hostname "${parsed.hostname}" — must be ${TRUSTED_HOST}

What it means

assertArbeitnowUrl's final check requires the hostname to equal the hardcoded TRUSTED_HOST ('www.arbeitnow.com'). A URL that parses and is HTTPS but points at a different host (arbeitnow.com without www, a mirror, a lookalike) throws this. It prevents the provider from being pointed at an arbitrary server.

Solutions

  1. Use the canonical host https://www.arbeitnow.com/api/job-board-api (FEED_BASE) — note the www is required by this validator.
  2. For local testing, stub ctx.fetchJson rather than substituting localhost URLs into the validator.
  3. If a mirror is genuinely needed, change TRUSTED_HOST/FEED_BASE in providers/arbeitnow.mjs deliberately, with review — never bypass the check.
  4. Copy URLs from the provider constants instead of typing them, to avoid www/typo drift.

Example fix

// before
const url = 'https://arbeitnow.com/api/job-board-api?page=1'; // no www
// after
const url = 'https://www.arbeitnow.com/api/job-board-api?page=1';
Defensive patterns

Strategy: validation

Validate before calling

const u = new URL(url);
if (u.hostname !== 'www.arbeitnow.com') throw new Error(`untrusted host ${u.hostname} — use www.arbeitnow.com`);

Type guard

function isTrustedArbeitnowUrl(s) {
  try { const u = new URL(s); return u.protocol === 'https:' && u.hostname === 'www.arbeitnow.com'; } catch { return false; }
}

Try / catch

try {
  await provider.fetch(entry, ctx);
} catch (err) {
  if (String(err.message).includes('untrusted hostname')) {
    console.error(`Host mismatch (${err.message}) — remember the canonical host includes "www"`);
  }
  throw err;
}

Prevention

When it happens

Trigger: URL host is not exactly 'www.arbeitnow.com' — e.g. 'https://arbeitnow.com/api/job-board-api' (missing www), a proxy/mirror host like 'arbeitnow.internal' or 'localhost', or a typo'd host ('wwww.arbeitnow.com').

Common situations: Dropping the www when hand-typing the API URL; pointing the provider at a corporate proxy or local stub during development; DNS-based redirects that don't change the URL string but a config rewrite did; forks swapping in a mirror endpoint.

Understand the failure class

Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.

Related errors


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

Appendix: source

Thrown at providers/arbeitnow.mjs:34

// Wire in via a `job_boards:` entry with `provider: arbeitnow`.

const FEED_BASE = 'https://www.arbeitnow.com/api/job-board-api';
const TRUSTED_HOST = 'www.arbeitnow.com';
const PER_PAGE = 100;
const DEFAULT_MAX_PAGES = 3;
const MAX_PAGES_CAP = 50;

/** @param {string} url */
function assertArbeitnowUrl(url) {
  let parsed;
  try {
    parsed = new URL(url);
  } catch {
    throw new Error(`arbeitnow: invalid URL: ${url}`);
  }
  if (parsed.protocol !== 'https:') throw new Error(`arbeitnow: URL must use HTTPS: ${url}`);
  if (parsed.hostname !== TRUSTED_HOST) {
    throw new Error(`arbeitnow: untrusted hostname "${parsed.hostname}" — must be ${TRUSTED_HOST}`);
  }
  return url;
}

/** Resolve the page cap: a positive integer `max_pages` on the entry, capped. */
function resolveMaxPages(entry) {
  const v = entry?.max_pages;
  if (Number.isInteger(v) && v > 0) return Math.min(v, MAX_PAGES_CAP);
  return DEFAULT_MAX_PAGES;
}

/**
 * Normalize a single Arbeitnow job. Exported for unit tests.
 *
 * Field mapping → the normalized Job shape:
 *   - title:    `title`, trimmed (items without one are dropped).
 *   - url:      `url` — an absolute `https:` posting URL host-locked to
 *               www.arbeitnow.com (an off-host or non-https URL is untrusted and

View on GitHub (pinned to aac998c7ed)