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
- Make the URL absolute and well-formed: 'https://larajobs.com/...'.
- Check the portals.yml entry (or caller) for missing scheme, stray characters, or unresolved variables.
- Wrap construction with new URL(url) in a try/catch to validate before calling the provider.
- 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
- Validate portals.yml URLs at load time with new URL()
- Never build URLs by naive string concatenation without validating the result
- Ensure env-driven URLs have safe defaults and are non-empty
- Fail soft per entry so one bad URL doesn't abort the scan
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
- garena: is not a usable URL segment
- landingjobs: invalid URL
- lever: invalid URL
- nodesk: invalid URL
- nofluffjobs: invalid URL
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)