santifer/career-ops · error · Error

jobspresso: invalid URL: ${url}

Error message

jobspresso: invalid URL: ${url}

What it means

Thrown by assertJobspressoUrl when new URL(url) throws — the supplied string is not a parseable absolute URL. The shipped fetch() path only passes the hardcoded FEED_URL constant ('https://jobspresso.co/?feed=job_feed', which always parses) through the assert, so from the public contract this branch is effectively unreachable. It is an SSRF defense-in-depth guard that activates if FEED_URL is edited to a malformed value or the assert is reused on caller input.

Source

Thrown at providers/jobspresso.mjs:20

/** @typedef {import('./_types.js').Provider} Provider */

// Jobspresso provider - public WordPress jobs feed
// (https://jobspresso.co/?feed=job_feed). The feed is public, no-auth,
// and XML, so it is parsed in-process with the same tiny tag extractor
// approach as providers/personio.mjs rather than adding an XML dependency.
//
// Wire in via a `job_boards:` entry with `provider: jobspresso`.

const FEED_URL = 'https://jobspresso.co/?feed=job_feed';
const TRUSTED_HOST = 'jobspresso.co';

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

// NaN-safe Date.parse - `|| undefined` would also coerce a valid epoch 0.
function toEpochMs(value) {
  if (!value) return undefined;
  const parsed = Date.parse(value);
  return Number.isNaN(parsed) ? undefined : parsed;
}

View on GitHub (pinned to 9b17a8ac97)

Solutions

  1. Restore FEED_URL to a well-formed absolute URL: https://jobspresso.co/?feed=job_feed.
  2. Pre-validate any caller-supplied URL before passing it to assertJobspressoUrl.
  3. Add a unit test asserting new URL(FEED_URL) does not throw.

Example fix

// before
const FEED_URL = 'jobspresso.co/?feed=job_feed'; // missing scheme

// after
const FEED_URL = 'https://jobspresso.co/?feed=job_feed';
Defensive patterns

Strategy: validation

Validate before calling

// Validate any caller URL (or the FEED_URL constant) before the assert throws.
function parseOrThrow(url) {
  try { return new URL(url); }
  catch { throw new Error(`jobspresso: invalid URL: ${url}`); }
}

Type guard

/** True for an absolute, parseable URL string. */
function isAbsoluteUrl(value) {
  if (typeof value !== 'string' || !value.trim()) return false;
  try { new URL(value); return true; } catch { return false; }
}

Try / catch

try {
  return await jobspressoProvider.fetch(entry, ctx);
} catch (err) {
  if (/jobspresso: invalid URL/.test(err.message)) {
    console.error(`jobspresso: FEED_URL constant is malformed — ${err.message}`);
  }
  throw err;
}

Prevention

When it happens

Trigger: A fork edit changing FEED_URL to a malformed value (missing scheme, stray characters); reusing assertJobspressoUrl on unvalidated entry/user input; a build step mangling the constant. The unmodified provider never triggers this.

Common situations: A developer forking the provider to a staging endpoint and typoing the URL; extending the provider to accept a configurable feed URL without pre-validation.

Related errors


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