{"record":{"id":"2eeb4e74ea310260","repo":"santifer/career-ops","slug":"weworkremotely-invalid-url-url","errorCode":null,"errorMessage":"weworkremotely: invalid URL: ${url}","messagePattern":"weworkremotely: invalid URL: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"providers/weworkremotely.mjs","lineNumber":21,"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":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/providers/weworkremotely.mjs#L3-L39","documentation":"The weworkremotely provider validates URLs through assertWwrUrl before use. If the string cannot be parsed by the WHATWG URL constructor at all (missing scheme, spaces, malformed percent-encoding, empty string), it throws this error. This is the first gate — before the HTTPS and hostname checks — so it fires on structurally broken input, not just wrong hosts.","triggerScenarios":"Passing a value like 'weworkremotely.com/remote-jobs.rss' (no scheme), an empty string, a URL with unencoded spaces or control characters, or a non-string value coerced to something unparseable into any code path that calls assertWwrUrl (e.g. a careers_url or feed URL from portals.yml).","commonSituations":"Config entries missing the https:// prefix, URLs pasted with surrounding whitespace/newlines that survived a trim, shell or template interpolation that produced 'https://undefined/...' or similar, URLs built by naive string concatenation.","solutions":["Add the missing scheme: prefix the value with https:// (e.g. https://weworkremotely.com/remote-jobs.rss)","Trim whitespace/newlines from the configured value and check for invisible characters","Verify with a quick sanity check: new URL(url) in a Node REPL should not throw","If the value is interpolated, log the exact final string before the call to see what actually got built"],"exampleFix":"// before\ncareers_url: weworkremotely.com/remote-jobs.rss\n// after\ncareers_url: https://weworkremotely.com/remote-jobs.rss","handlingStrategy":"validation","validationCode":"function isParsableUrl(url) {\n  try { new URL(url); return true; } catch { return false; }\n}\n// pre-check: isParsableUrl(entry.careers_url) else fix the string","typeGuard":"const isUrl = (v) => typeof v === 'string' && (() => { try { new URL(v); return true; } catch { return false; } })();","tryCatchPattern":"try {\n  await wwrProvider.fetch(entry, ctx);\n} catch (err) {\n  if (err.message.startsWith('weworkremotely: invalid URL')) {\n    console.error(`Bad URL for ${entry.name}: ${err.message} — add https:// and trim whitespace`);\n    return;\n  }\n  throw err;\n}","preventionTips":["Always include the scheme when storing URLs in config","Trim and normalize URL strings (strip whitespace/newlines) when loading config","Log the final interpolated URL string before provider calls during config debugging","Avoid building URLs by concatenation; prefer URL objects or template constants"],"tags":["url-validation","config","parse-error"],"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"}