santifer/career-ops · warning · Error

eightfold: invalid URL: ${url}

Error message

eightfold: invalid URL: ${url}

What it means

Thrown by eightfold's assertEightfoldUrl when new URL() cannot parse the value. It is defense-in-depth: in fetch() the URL is always built by buildApiUrl from a resolveTenant-validated host, so it is always a well-formed https URL and this branch is unreachable through normal use. Reachable only via a direct assertEightfoldUrl call.

Source

Thrown at providers/eightfold.mjs:69

const MAX_PAGES_CAP = 1000;
// Same-host pacing between pages inside one tenant's own pagination loop.
// Eightfold's edge rate-limits bursts, and a 616-job board is 62 requests.
const INTER_PAGE_DELAY_MS = 150;

const RETRY_POLICY = { retries: 3, baseDelayMs: 500, maxDelayMs: 8_000 };

/**
 * SSRF guard — every request URL passes through here before it is fetched.
 *
 * @param {string} url
 * @returns {string} the same URL, when it is a trusted Eightfold endpoint.
 */
function assertEightfoldUrl(url) {
  let parsed;
  try {
    parsed = new URL(url);
  } catch {
    throw new Error(`eightfold: invalid URL: ${url}`);
  }
  if (parsed.protocol !== 'https:') throw new Error(`eightfold: URL must use HTTPS: ${url}`);
  if (!EIGHTFOLD_HOST_RE.test(parsed.hostname)) {
    throw new Error(`eightfold: untrusted hostname "${parsed.hostname}" — must match *.eightfold.ai`);
  }
  return url;
}

/** @param {number} ms @param {any} ctx */
function sleep(ms, ctx) {
  if (typeof ctx?.sleep === 'function') return ctx.sleep(ms);
  return new Promise((resolve) => setTimeout(resolve, ms));
}

/**
 * Eightfold reports timestamps as epoch SECONDS (`t_create`, `t_update`), not
 * the ISO strings every other provider gets. Converted here; anything
 * non-finite or non-positive is dropped rather than guessed at.

View on GitHub (pinned to 9b17a8ac97)

Solutions

  1. For direct callers, validate the value parses as a URL first.
  2. For normal fetch() use, no action — buildApiUrl always yields a valid URL.
  3. Treat a production hit as a signal that the URL is no longer built solely via buildApiUrl.

Example fix

// before — direct call on raw input
assertEightfoldUrl(maybeUrl);

// after — validate first
try { new URL(maybeUrl); } catch { /* not a URL, skip */ }
Defensive patterns

Strategy: validation

Validate before calling

// Through fetch() unreachable (URL built via buildApiUrl from a validated tenant). For a direct call:
function isParseableUrl(u) { try { new URL(u); return true; } catch { return false; } }

Type guard

function isParseableUrl(u) {
  if (typeof u !== 'string' || !u) return false;
  try { new URL(u); return true; } catch { return false; }
}

Try / catch

try { assertEightfoldUrl(url); }
catch (e) {
  if (/^eightfold: invalid URL/.test(e.message)) { /* input wasn't a URL — skip */ }
  else throw e;
}

Prevention

When it happens

Trigger: assertEightfoldUrl is called directly with a non-URL value. fetch() constructs the URL via buildApiUrl(tenant,...) where tenant.host already matched EIGHTFOLD_HOST_RE, so no entry config produces a malformed URL here.

Common situations: A unit test or custom integration calling assertEightfoldUrl on raw input. Production scans do not reach this branch.

Related errors


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