santifer/career-ops · error · Error
jobbankca: invalid URL
Error message
jobbankca: invalid URL: ${url} What it means
assertJobBankUrl validates any URL used by the Job Bank Canada provider before it is fetched. It throws 'invalid URL' when the string cannot be parsed by the WHATWG URL constructor (new URL(url) throws) — meaning the value is not a well-formed absolute URL. This is the first gate before the HTTPS and hostname checks, guarding the provider against malformed or attacker-controlled configuration (SSRF defense).
Solutions
- Print the exact url value passed in and fix the job_boards entry in portals.yml so it is a full absolute URL starting with https://
- Verify no YAML/env interpolation left a literal placeholder like ${url} in the config
- Validate the URL manually in Node: new URL('...') in a REPL and fix until it parses
- If constructing URLs programmatically, use encodeURIComponent on query components and build from the known-good FEED_URL base
Example fix
// before api: jobbank.gc.ca/jobsearch/feed/jobSearchRSSfeed // after api: https://www.jobbank.gc.ca/jobsearch/feed/jobSearchRSSfeed
Defensive patterns
Strategy: validation
Validate before calling
function isValidJobBankUrl(url) {
try {
return new URL(url).protocol === 'https:' && new URL(url).hostname === 'www.jobbank.gc.ca';
} catch {
return false;
}
} Type guard
function isHttpUrl(v) {
return typeof v === 'string' && v.length > 0 && URL.canParse(v);
} Try / catch
try {
assertJobBankUrl(cfg.api);
} catch (e) {
if (/invalid URL/.test(e.message)) {
console.error(`Bad config URL for jobbankca: ${JSON.stringify(cfg.api)} — must be absolute https://`);
return [];
}
throw e;
} Prevention
- Always store full absolute https:// URLs in portals.yml entries
- Run node doctor.mjs / verify-pipeline.mjs before scans to catch config problems
- Avoid hand-templating URLs from env vars without validating the result
- Use URL.canParse() (Node 19.9+) for cheap pre-checks
When it happens
Trigger: Calling assertJobBankUrl(url) — directly or via the jobbankca provider fetch path — with a value like '', 'jobbank.gc.ca/jobsearch', 'https://' , a URL with invalid characters, or a relative path, so new URL(url) throws a TypeError.
Common situations: A typo'd or missing careers_url/api field in the job_boards entry of portals.yml; an env-var placeholder ('${API_URL}') left unsubstituted; YAML folding that mangles the URL; passing a path instead of a full absolute URL.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- jobspresso: invalid URL
- jobstreet: invalid URL
- himalayas: untrusted hostname
- itviec: untrusted hostname
- jobstreet: URL must use HTTPS
AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16).
Data as JSON: /api/errors/4138ddbc8a79d767.
Report an issue: GitHub.
Appendix: source
Thrown at providers/jobbankca.mjs:98
const keywords = Array.isArray(cfg.keywords)
? cfg.keywords.filter((k) => typeof k === 'string' && k.trim()).map((k) => k.trim())
: [];
return { keywords };
}
/** @param {string} keyword @param {number} page */
export function buildFeedUrl(keyword, page) {
const params = new URLSearchParams({ searchstring: keyword, locationstring: '', page: String(page) });
return `${FEED_URL}?${params.toString()}`;
}
/** @param {string} url */
export function assertJobBankUrl(url) {
let parsed;
try {
parsed = new URL(url);
} catch {
throw new Error(`jobbankca: invalid URL: ${url}`);
}
if (parsed.protocol !== 'https:') throw new Error(`jobbankca: URL must use HTTPS: ${url}`);
if (parsed.hostname !== TRUSTED_HOST) {
throw new Error(`jobbankca: untrusted hostname "${parsed.hostname}" — must be ${TRUSTED_HOST}`);
}
return url;
}
// Resolve an Atom element's inner text: unwrap CDATA, else decode entities.
function extractText(inner) {
const cdata = inner.match(/^\s*<!\[CDATA\[([\s\S]*?)\]\]>\s*$/);
if (cdata) return cdata[1].trim();
return decodeEntities(inner).trim();
}
function tagText(block, tag) {
const m = block.match(new RegExp(`<${tag}\\b[^>]*>([\\s\\S]*?)</${tag}>`, 'i'));
return m ? extractText(m[1]) : '';View on GitHub (pinned to aac998c7ed)