santifer/career-ops · error · Error

landingjobs: untrusted hostname

Error message

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

What it means

assertLandingUrl enforces a host allowlist of exactly one trusted host (TRUSTED_HOST). A syntactically valid HTTPS URL pointing at any other hostname is rejected. This is an SSRF/pin hardening measure: even a correct-looking URL must land on the expected API host.

Solutions

  1. Correct the hostname in the URL/config so it exactly matches TRUSTED_HOST (check for 'www.', wrong TLD, or a proxy domain).
  2. Inspect the TRUSTED_HOST constant in providers/landingjobs.mjs to see the accepted value and align your URL with it.
  3. If you need a different host for testing, raise it with the maintainers rather than bypassing the assertion.
  4. Note the error message interpolates the actual parsed hostname — use it to spot the mismatch precisely.

Example fix

// before
assertLandingUrl('https://api.landingjobs.io/v1/jobs');
// after
assertLandingUrl('https://landingjobs.co/api/jobs'); // hostname must equal TRUSTED_HOST
Defensive patterns

Strategy: validation

Validate before calling

const TRUSTED_HOST = 'landingjobs.co';
function isTrustedHost(u) { try { return new URL(u).hostname === TRUSTED_HOST; } catch { return false; } }
if (!isTrustedHost(url)) throw new Error(`host not allowed: ${url}`);

Type guard

function isTrustedUrl(v) { if (typeof v !== 'string') return false; try { return new URL(v).hostname === TRUSTED_HOST && new URL(v).protocol === 'https:'; } catch { return false; } }

Try / catch

try {
  provider.fetch(entry, ctx);
} catch (e) {
  if (e.message.includes('untrusted hostname')) {
    console.error(`Entry points at wrong host: ${e.message}; fix portals.yml`);
    return null;
  }
  throw e;
}

Prevention

When it happens

Trigger: Passing an HTTPS URL whose parsed hostname differs from TRUSTED_HOST — e.g. a mirror domain, 'www.'-prefixed variant, or an attacker-controlled lookalike host — to assertLandingUrl or the provider fetch path.

Common situations: Config entry pointing at a custom proxy or alternate domain, a typo like 'landingjobs.com' vs the real TLD, or intentionally swapping in a mock/test server URL.

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/12d6ac28a7e6cfbe. Report an issue: GitHub.

Appendix: source

Thrown at providers/landingjobs.mjs:30

// `company` is derived best-effort from that slug (humanized) and falls back to
// the portal entry name. The whole active set is returned in one call.
//
// Wire in via a `job_boards:` entry with `provider: landingjobs`.

const FEED_URL = 'https://landing.jobs/api/v1/jobs';
const TRUSTED_HOST = 'landing.jobs';

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

// NaN-safe Date.parse.
function toEpochMs(value) {
  if (typeof value !== 'string' || !value) return undefined;
  const parsed = Date.parse(value);
  return Number.isNaN(parsed) ? undefined : parsed;
}

/**
 * Derive a best-effort company name from a Landing.jobs posting URL.
 * Posting URLs are `https://landing.jobs/at/<slug>/<job>`; the `<slug>` is
 * humanized (hyphens/underscores → spaces, title-cased). Returns '' when the
 * URL is not the expected `/at/<slug>/…` shape. Exported for unit tests.
 * @param {string} url
 */

View on GitHub (pinned to aac998c7ed)