{"record":{"id":"fd22a60af5b0b5cb","repo":"santifer/career-ops","slug":"arbeitnow-invalid-url-url","errorCode":null,"errorMessage":"arbeitnow: invalid URL: ${url}","messagePattern":"arbeitnow: invalid URL: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"providers/arbeitnow.mjs","lineNumber":30,"sourceCode":"// scan.mjs's title_filter then gates on the configured titles. Pages are fetched\n// until one comes back short/empty or the page cap is reached (default 3,\n// override with `max_pages` on the portal entry).\n//\n// Wire in via a `job_boards:` entry with `provider: arbeitnow`.\n\nconst FEED_BASE = 'https://www.arbeitnow.com/api/job-board-api';\nconst TRUSTED_HOST = 'www.arbeitnow.com';\nconst PER_PAGE = 100;\nconst DEFAULT_MAX_PAGES = 3;\nconst MAX_PAGES_CAP = 50;\n\n/** @param {string} url */\nfunction assertArbeitnowUrl(url) {\n  let parsed;\n  try {\n    parsed = new URL(url);\n  } catch {\n    throw new Error(`arbeitnow: invalid URL: ${url}`);\n  }\n  if (parsed.protocol !== 'https:') throw new Error(`arbeitnow: URL must use HTTPS: ${url}`);\n  if (parsed.hostname !== TRUSTED_HOST) {\n    throw new Error(`arbeitnow: untrusted hostname \"${parsed.hostname}\" — must be ${TRUSTED_HOST}`);\n  }\n  return url;\n}\n\n/** Resolve the page cap: a positive integer `max_pages` on the entry, capped. */\nfunction resolveMaxPages(entry) {\n  const v = entry?.max_pages;\n  if (Number.isInteger(v) && v > 0) return Math.min(v, MAX_PAGES_CAP);\n  return DEFAULT_MAX_PAGES;\n}\n\n/**\n * Normalize a single Arbeitnow job. Exported for unit tests.\n *","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/providers/arbeitnow.mjs#L12-L48","documentation":"assertArbeitnowUrl first checks that the URL parses with the URL constructor; if new URL(url) throws (malformed URL), this error is thrown with the offending string. It's the initial sanity gate before the HTTPS and trusted-host checks on every URL the arbeitnow provider fetches.","triggerScenarios":"new URL(url) throws for input like an empty string, a relative path ('api/job-board-api?page=1' without origin), whitespace/control characters, or a template literal that interpolated undefined ('https://www.arbeitnow.com/api/job-board-api?page=undefined' parses fine — so this fires mainly for missing origin, null/undefined coerced to 'null'/'undefined', or garbage config values).","commonSituations":"Config/portal entry with a missing or mistyped base URL; a variable holding the URL is undefined and string-interpolates into a broken value; code refactor accidentally passes a path instead of an absolute URL; tests passing relative URLs.","solutions":["Log/print the exact url string in the message and fix its source — usually an undefined/empty base variable or a relative path missing the https://www.arbeitnow.com origin.","Use the provider's own FEED_BASE ('https://www.arbeitnow.com/api/job-board-api') when building page URLs instead of hand-rolling strings.","Validate configured URLs at startup (new URL(entry.url)) so a bad portals.yml entry fails fast with a clear config error.","If testing, always pass absolute URLs to assertArbeitnowUrl."],"exampleFix":"// before\nconst url = `${base}?page=${page}`; // base undefined -> \"undefined?page=1\"\nassertArbeitnowUrl(url); // throws: invalid URL\n// after\nconst base = 'https://www.arbeitnow.com/api/job-board-api';\nassertArbeitnowUrl(`${base}?page=${page}`);","handlingStrategy":"validation","validationCode":"let parsed;\ntry { parsed = new URL(entryUrl); } catch { throw new Error(`portal entry has a malformed URL: ${JSON.stringify(entryUrl)}`); }\nif (!parsed.hostname) throw new Error('portal entry URL has no host');","typeGuard":"function isAbsoluteHttpUrl(s) {\n  if (typeof s !== 'string') return false;\n  try { const u = new URL(s); return u.protocol === 'http:' || u.protocol === 'https:'; } catch { return false; }\n}","tryCatchPattern":"try {\n  await provider.fetch(entry, ctx);\n} catch (err) {\n  if (String(err.message).includes('invalid URL')) {\n    console.error(`Bad URL for entry \"${entry.name}\": check that the base is a full absolute https:// URL and no interpolated variable was undefined`);\n  }\n  throw err;\n}","preventionTips":["Validate all portal entry URLs at config load time with new URL() so failures surface as config errors, not fetch errors.","Build URLs from the provider's FEED_BASE constant instead of string literals.","Watch for undefined/empty variables interpolating into template literals — 'undefined' sneaks into URLs easily."],"tags":["url","validation","config","provider"],"backgroundTag":"invalid-url-format","analyzedSha":"aac998c7ed7248ea853b720ceeb1fdbeb322fc5d","analyzedAt":"2026-09-16T06:35:29.214Z","contentChangedAt":"2026-09-16T06:35:29.214Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}