{"record":{"id":"3b8569c5d792fdf6","repo":"santifer/career-ops","slug":"larajobs-invalid-url-url","errorCode":null,"errorMessage":"larajobs: invalid URL: ${url}","messagePattern":"larajobs: invalid URL: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"providers/larajobs.mjs","lineNumber":24,"sourceCode":"// and XML, so it is parsed in-process with the same tiny tag extractor as\n// providers/nodesk.mjs rather than adding an XML dependency.\n//\n// Each <item> carries the standard RSS fields plus a `job:` namespace with\n// `<job:company>` and `<job:location>`, so company and location come straight\n// from the feed (no title-splitting heuristics needed).\n//\n// Wire in via a `job_boards:` entry with `provider: larajobs`.\n\nconst FEED_URL = 'https://larajobs.com/feed';\nconst TRUSTED_HOST = 'larajobs.com';\n\n/** @param {string} url */\nfunction assertLarajobsUrl(url) {\n  let parsed;\n  try {\n    parsed = new URL(url);\n  } catch {\n    throw new Error(`larajobs: invalid URL: ${url}`);\n  }\n  if (parsed.protocol !== 'https:') throw new Error(`larajobs: URL must use HTTPS: ${url}`);\n  if (parsed.hostname !== TRUSTED_HOST) {\n    throw new Error(`larajobs: 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() : 'LaraJobs';\n}","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/santifer/career-ops/blob/9b17a8ac97b398a496b38e423ae24e433b43254f/providers/larajobs.mjs#L6-L42","documentation":"assertLarajobsUrl runs the value through the WHATWG URL constructor; if construction throws (the string is not an absolute, parseable URL), this error is raised. It is the first of three sequential guards (parse → HTTPS → trusted host) protecting the feed fetch from malformed or malicious URLs.","triggerScenarios":"entry.api or a constructed URL passed to assertLarajobsUrl is an empty string, a relative path like '/feed', a string with embedded spaces/control chars, a missing-scheme string like 'larajobs.com/feed', or any value the URL constructor rejects.","commonSituations":"portals.yml has a typo in an api: field (missing https://), a templated URL was left blank, or the FEED_URL constant was edited to a relative path. Also fires if a stray whitespace/newline was copied into the config.","solutions":["Inspect the value printed in the message — it is the exact string that failed to parse.","Ensure the URL has an explicit scheme, e.g. https://larajobs.com/feed.","Trim whitespace in the config source (portals.yml) and re-run.","If the URL is user-supplied, validate with new URL(...) in your own config loader before it reaches the provider."],"exampleFix":"// before (config)\napi: larajobs.com/feed\n\n// after\napi: https://larajobs.com/feed","handlingStrategy":"validation","validationCode":"// Validate entry URLs in your config loader BEFORE the provider sees them.\nimport { URL } from 'node:url';\nexport function isValidAbsoluteUrl(value) {\n  if (typeof value !== 'string' || !value) return false;\n  try { new URL(value); return true; } catch { return false; }\n}\n// if (!isValidAbsoluteUrl(entry.api)) failConfig('larajobs api is not a valid URL');","typeGuard":"/** @param {string} url */\nfunction isParseableUrl(url) {\n  try { new URL(url); return true; } catch { return false; }\n}","tryCatchPattern":"// detect() already swallows this; for direct calls, catch and degrade gracefully.\ntry {\n  assertLarajobsUrl(candidate);\n} catch (err) {\n  // mark the entry as misconfigured and exclude from the run\n  entry.disabled = true;\n  console.warn(`disabling ${entry.name}: ${err.message}`);\n}","preventionTips":["Run a config pre-flight pass over portals.yml that asserts every api:/careers_url parses as a URL.","Always include the https:// scheme in config URLs — never bare hostnames.","Treat an empty api: field as a config error at load time, not at fetch time.","Use a linter/schema validator for portals.yml to catch malformed URLs before runtime."],"tags":["url-validation","config","larajobs","ssrf-guard"],"backgroundTag":null,"analyzedSha":"9b17a8ac97b398a496b38e423ae24e433b43254f","analyzedAt":"2026-08-13T00:48:39.135Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}