{"record":{"id":"2eeb4e74ea310260","repo":"santifer/career-ops","slug":"weworkremotely-invalid-url-url","errorCode":null,"errorMessage":"weworkremotely: invalid URL: ${url}","messagePattern":"weworkremotely: invalid URL: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"providers/weworkremotely.mjs","lineNumber":20,"sourceCode":"/** @typedef {import('./_types.js').Provider} Provider */\n\n// We Work Remotely provider - board-wide RSS feed\n// (https://weworkremotely.com/remote-jobs.rss). The feed is public, no-auth,\n// and XML, so it is parsed in-process with the same tiny tag extractor approach\n// as providers/personio.mjs rather than adding an XML dependency.\n//\n// Wire in via a `job_boards:` entry with `provider: weworkremotely`.\n\nconst FEED_URL = 'https://weworkremotely.com/remote-jobs.rss';\nconst TRUSTED_HOST = 'weworkremotely.com';\n\n/** @param {string} url */\nfunction assertWwrUrl(url) {\n  let parsed;\n  try {\n    parsed = new URL(url);\n  } catch {\n    throw new Error(`weworkremotely: invalid URL: ${url}`);\n  }\n  if (parsed.protocol !== 'https:') throw new Error(`weworkremotely: URL must use HTTPS: ${url}`);\n  if (parsed.hostname !== TRUSTED_HOST) {\n    throw new Error(`weworkremotely: untrusted hostname \"${parsed.hostname}\" - must be ${TRUSTED_HOST}`);\n  }\n  return url;\n}\n\n// NaN-safe Date.parse - `|| undefined` would also coerce a valid epoch 0.\nfunction toEpochMs(value) {\n  if (!value) return undefined;\n  const parsed = Date.parse(value);\n  return Number.isNaN(parsed) ? undefined : parsed;\n}\n\nfunction fallbackCompany(entry) {\n  return typeof entry?.name === 'string' && entry.name.trim() ? entry.name.trim() : 'We Work Remotely';\n}","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/santifer/career-ops/blob/9b17a8ac97b398a496b38e423ae24e433b43254f/providers/weworkremotely.mjs#L2-L38","documentation":"assertWwrUrl is an SSRF guard that pins every request this provider makes to https://weworkremotely.com. This branch fires when new URL(url) throws — the string is not parseable as an absolute URL at all. In production it is only ever called with the module constant FEED_URL, so it is effectively a maintainer-invariant guard, not a user-configurable error.","triggerScenarios":"Reached only with the FEED_URL constant (line 49). Fires if a maintainer edits FEED_URL into something new URL() rejects (empty string, embedded NUL, missing scheme). Not reachable from portals.yml config.","commonSituations":"A PR that refactors FEED_URL and breaks it; a bad merge; running a patched fork that changed the constant.","solutions":["Restore FEED_URL to https://weworkremotely.com/remote-jobs.rss.","If you intentionally changed the host, keep it an absolute https URL.","Add a unit test asserting assertWwrUrl(FEED_URL) does not throw."],"exampleFix":"// before\nconst FEED_URL = 'weworkremotely.com/remote-jobs.rss'; // missing scheme\n// after\nconst FEED_URL = 'https://weworkremotely.com/remote-jobs.rss';","handlingStrategy":"validation","validationCode":"// sanity-check module constants at load time rather than at first request\nconst FEED_URL = 'https://weworkremotely.com/remote-jobs.rss';\ntry { new URL(FEED_URL); }\ncatch { throw new Error(`weworkremotely: FEED_URL constant is malformed: ${FEED_URL}`); }","typeGuard":"const isAbsoluteUrl = (s) => { try { new URL(s); return true; } catch { return false; } };","tryCatchPattern":null,"preventionTips":["Never source this URL from user config — keep it a module constant.","Unit-test assertWwrUrl against the real FEED_URL so a broken constant fails CI, not a scan."],"tags":["validation","url","ssrf-guard","weworkremotely","invariant"],"backgroundTag":null,"analyzedSha":"9b17a8ac97b398a496b38e423ae24e433b43254f","analyzedAt":"2026-08-13T00:48:39.135Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}