santifer/career-ops · error · Error

jobbankca: URL must use HTTPS

Error message

jobbankca: URL must use HTTPS: ${url}

What it means

assertJobBankUrl rejects any URL whose parsed protocol is not 'https:'. The Job Bank provider only talks to the trusted federal feed over TLS; http://, ftp://, or custom schemes are refused to prevent plaintext traffic and downgrade/SSRF tricks. The check runs after URL parsing succeeds and before the hostname allowlist check.

Solutions

  1. Change the URL scheme in the portals.yml job_boards entry to https://
  2. Confirm the certificate is valid — if you used http because of TLS errors, fix the cert rather than downgrading
  3. If you need an http test endpoint, do not use this provider; it hard-requires https

Example fix

// before
assertJobBankUrl('http://www.jobbank.gc.ca/jobsearch/feed/jobSearchRSSfeed');
// after
assertJobBankUrl('https://www.jobbank.gc.ca/jobsearch/feed/jobSearchRSSfeed');
Defensive patterns

Strategy: validation

Validate before calling

function isHttpsUrl(url) {
  try { return new URL(url).protocol === 'https:'; } catch { return false; }
}

Type guard

function assertHttps(u) {
  const p = URL.canParse(u) ? new URL(u) : null;
  if (!p || p.protocol !== 'https:') throw new TypeError(`not https: ${u}`);
  return p;
}

Try / catch

try {
  assertJobBankUrl(u);
} catch (e) {
  if (/must use HTTPS/.test(e.message)) {
    u = u.replace(/^http:/, 'https:'); // or fail the entry
  } else throw e;
}

Prevention

When it happens

Trigger: Calling assertJobBankUrl with e.g. 'http://www.jobbank.gc.ca/jobsearch/feed/jobSearchRSSfeed' or any non-https scheme that still parses as a valid URL.

Common situations: Config entry written with http:// instead of https://; a local testing URL (http://localhost) plugged into the provider config; a migration from an older non-TLS mirror 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


AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16). Data as JSON: /api/errors/c491ceb41413f773. Report an issue: GitHub.

Appendix: source

Thrown at providers/jobbankca.mjs:100

    : [];
  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)