{"record":{"id":"3b8569c5d792fdf6","repo":"santifer/career-ops","slug":"larajobs-invalid-url-url","errorCode":null,"errorMessage":"larajobs: invalid URL: ${url}","messagePattern":"larajobs: invalid URL: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"providers/larajobs.mjs","lineNumber":25,"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":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/providers/larajobs.mjs#L7-L43","documentation":"The larajobs provider mirrors landingjobs' URL validation via assertLarajobsUrl: any URL the URL constructor cannot parse throws this error. It fails fast before any network activity and names the module ('larajobs:') so the source of the bad value is identifiable in logs.","triggerScenarios":"Calling assertLarajobsUrl (directly or through the provider's fetch) with a string that fails new URL(): empty string, no scheme, spaces, or unresolved template placeholders like '${url}'.","commonSituations":"Malformed careers_url in portals.yml (missing https://), an env-var-driven URL left unset so an empty/placeholder string reaches the validator, or string concatenation that drops part of the URL.","solutions":["Make the URL absolute and well-formed: 'https://larajobs.com/...'.","Check the portals.yml entry (or caller) for missing scheme, stray characters, or unresolved variables.","Wrap construction with new URL(url) in a try/catch to validate before calling the provider.","Print the offending value from the error message and diff it against the expected endpoint."],"exampleFix":"// before\nassertLarajobsUrl(process.env.LARAJOBS_URL ?? '');\n// after\nconst u = process.env.LARAJOBS_URL ?? 'https://larajobs.com/api/jobs';\nassertLarajobsUrl(u);","handlingStrategy":"validation","validationCode":"function isValidUrl(u) { try { new URL(u); return true; } catch { return false; } }\nif (!isValidUrl(url)) throw new Error(`skipping larajobs entry: invalid URL ${url}`);","typeGuard":"function isParseableUrl(v) { return typeof v === 'string' && (() => { try { new URL(v); return true; } catch { return false; } })(); }","tryCatchPattern":"try {\n  provider.fetch(entry, ctx);\n} catch (e) {\n  if (e.message.startsWith('larajobs: invalid URL')) {\n    console.error(`Bad larajobs config: ${e.message}`);\n    return null;\n  }\n  throw e;\n}","preventionTips":["Validate portals.yml URLs at load time with new URL()","Never build URLs by naive string concatenation without validating the result","Ensure env-driven URLs have safe defaults and are non-empty","Fail soft per entry so one bad URL doesn't abort the scan"],"tags":["url-validation","config","input-validation"],"backgroundTag":"invalid-url","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"}