santifer/career-ops · error · Error

larajobs: invalid URL

Error message

larajobs: invalid URL: ${url}

What it means

The larajobs provider mirrors landingjobs' URL validation via assertLarajobsUrl: any URL the URL constructor cannot parse throws this error. It fails fast before any network activity and names the module ('larajobs:') so the source of the bad value is identifiable in logs.

Solutions

  1. Make the URL absolute and well-formed: 'https://larajobs.com/...'.
  2. Check the portals.yml entry (or caller) for missing scheme, stray characters, or unresolved variables.
  3. Wrap construction with new URL(url) in a try/catch to validate before calling the provider.
  4. Print the offending value from the error message and diff it against the expected endpoint.

Example fix

// before
assertLarajobsUrl(process.env.LARAJOBS_URL ?? '');
// after
const u = process.env.LARAJOBS_URL ?? 'https://larajobs.com/api/jobs';
assertLarajobsUrl(u);
Defensive patterns

Strategy: validation

Validate before calling

function isValidUrl(u) { try { new URL(u); return true; } catch { return false; } }
if (!isValidUrl(url)) throw new Error(`skipping larajobs entry: invalid URL ${url}`);

Type guard

function isParseableUrl(v) { return typeof v === 'string' && (() => { try { new URL(v); return true; } catch { return false; } })(); }

Try / catch

try {
  provider.fetch(entry, ctx);
} catch (e) {
  if (e.message.startsWith('larajobs: invalid URL')) {
    console.error(`Bad larajobs config: ${e.message}`);
    return null;
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling assertLarajobsUrl (directly or through the provider's fetch) with a string that fails new URL(): empty string, no scheme, spaces, or unresolved template placeholders like '${url}'.

Common situations: Malformed careers_url in portals.yml (missing https://), an env-var-driven URL left unset so an empty/placeholder string reaches the validator, or string concatenation that drops part of the 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/3b8569c5d792fdf6. Report an issue: GitHub.

Appendix: source

Thrown at providers/larajobs.mjs:25

// and XML, so it is parsed in-process with the same tiny tag extractor as
// providers/nodesk.mjs rather than adding an XML dependency.
//
// Each <item> carries the standard RSS fields plus a `job:` namespace with
// `<job:company>` and `<job:location>`, so company and location come straight
// from the feed (no title-splitting heuristics needed).
//
// Wire in via a `job_boards:` entry with `provider: larajobs`.

const FEED_URL = 'https://larajobs.com/feed';
const TRUSTED_HOST = 'larajobs.com';

/** @param {string} url */
function assertLarajobsUrl(url) {
  let parsed;
  try {
    parsed = new URL(url);
  } catch {
    throw new Error(`larajobs: invalid URL: ${url}`);
  }
  if (parsed.protocol !== 'https:') throw new Error(`larajobs: URL must use HTTPS: ${url}`);
  if (parsed.hostname !== TRUSTED_HOST) {
    throw new Error(`larajobs: 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;
}

function fallbackCompany(entry) {
  return typeof entry?.name === 'string' && entry.name.trim() ? entry.name.trim() : 'LaraJobs';
}

View on GitHub (pinned to aac998c7ed)