santifer/career-ops · error · Error

arbeitnow: invalid URL: ${url}

Error message

arbeitnow: invalid URL: ${url}

What it means

The arbeitnow provider validates every URL through `assertArbeitnowUrl` before fetching. The 'invalid URL' variant fires when `new URL(url)` itself throws — the input is not parseable as an absolute URL. In the current code path it is called on the constant `FEED_BASE`, so in practice it guards against a tampered/overridden base URL or a future caller passing user input.

Source

Thrown at providers/arbeitnow.mjs:30

// scan.mjs's title_filter then gates on the configured titles. Pages are fetched
// until one comes back short/empty or the page cap is reached (default 3,
// override with `max_pages` on the portal entry).
//
// 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.
 *

View on GitHub (pinned to 9b17a8ac97)

Solutions

  1. Ensure the URL is absolute with an explicit scheme: `https://www.arbeitnow.com/api/job-board-api`.
  2. If sourcing the URL from config, validate/normalize it once at load time rather than at every fetch.
  3. Check for accidental whitespace or template-literal interpolation producing an empty scheme.

Example fix

// before — schemeless/relative
const FEED_BASE = 'www.arbeitnow.com/api/job-board-api';

// after
const FEED_BASE = 'https://www.arbeitnow.com/api/job-board-api';
Defensive patterns

Strategy: validation

Validate before calling

// Validate the base URL is an absolute https URL before passing it to the provider
function isValidAbsoluteHttpsUrl(u) {
  try {
    const p = new URL(u);
    return p.protocol === 'https:';
  } catch {
    return false;
  }
}
if (!isValidAbsoluteHttpsUrl(FEED_BASE)) {
  throw new Error(`arbeitnow: FEED_BASE is not an absolute https URL: ${FEED_BASE}`);
}

Prevention

When it happens

Trigger: `assertArbeitnowUrl(url)` is called with a string that `new URL()` cannot parse: a schemeless host (`www.arbeitnow.com/api`), a protocol-relative URL (`//www.arbeitnow.com`), an empty string, or a value containing illegal characters.

Common situations: Overriding `FEED_BASE` with a relative or schemeless string, env/config injection that strips the `https://` scheme, or wiring user-supplied URLs into the fetch path.

Related errors


AI-assisted analysis of santifer/career-ops@9b17a8ac97 (2026-08-13). Data as JSON: /api/errors/fd22a60af5b0b5cb. Report an issue: GitHub.