{"record":{"id":"0ba1779792a4f849","repo":"santifer/career-ops","slug":"yourator-invalid-url-url","errorCode":null,"errorMessage":"yourator: invalid URL: ${url}","messagePattern":"yourator: invalid URL: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"providers/yourator.mjs","lineNumber":81,"sourceCode":"// Per the Job contract, postedAt is omitted rather than guessed — a synthesized\n// date would silently corrupt scan-ats-full.mjs's recency filtering.\n\nconst SITE_ORIGIN = 'https://www.yourator.co';\nconst FEED_BASE = `${SITE_ORIGIN}/api/v4/jobs`;\nconst TRUSTED_HOST = 'www.yourator.co';\n// Safety bound only — the loop stops on payload.hasMore. The live board was 88\n// pages on 2026-08-18; this leaves room to grow without silently truncating.\nconst DEFAULT_MAX_PAGES = 120;\nconst MAX_PAGES_CAP = 500;\nconst PAGE_DELAY_MS = 200;\n\n/** @param {string} url */\nfunction assertYouratorUrl(url) {\n  let parsed;\n  try {\n    parsed = new URL(url);\n  } catch {\n    throw new Error(`yourator: invalid URL: ${url}`);\n  }\n  if (parsed.protocol !== 'https:') throw new Error(`yourator: URL must use HTTPS: ${url}`);\n  if (parsed.hostname !== TRUSTED_HOST) {\n    throw new Error(`yourator: 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 * Canonical URL for a posting — Source Indexing Policy rule 2, \"the shortest\n * verifiable path to the employer the source exposes\".","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/providers/yourator.mjs#L63-L99","documentation":"assertYouratorUrl parses a URL with new URL() before the yourator provider fetches it, throwing this error when parsing fails entirely. new URL throws on strings that are not absolute URLs — missing scheme, whitespace, malformed characters, or a relative path. This is the first of three guards (parse, HTTPS, host) ensuring the provider only ever fetches a well-formed address.","triggerScenarios":"Passing a relative path like '/companies/foo', a URL with unencoded spaces or invalid characters, an empty or non-string value coerced to something unparsable, or a typo like 'yourator.com/x' without the scheme.","commonSituations":"Config values copied from a browser address bar after the scheme was stripped; YAML values that lose the 'https://' prefix; template placeholders left in place; user input fed directly without validation.","solutions":["Prefix the value with https:// if the scheme is missing (e.g. 'yourator.net/en/companies/x' → 'https://yourator.net/...')","Trim whitespace and strip stray quotes/backticks from the configured URL","Encode illegal characters (spaces) or remove them from path segments","Validate the string with new URL() in the config layer before handing it to the provider"],"exampleFix":"// before\nconst url = cfg.companyUrl; // \"yourator.net/companies/acme\"\nassertYouratorUrl(url);\n// after\nconst raw = String(cfg.companyUrl).trim();\nconst url = raw.startsWith('http') ? raw : `https://${raw}`;\nassertYouratorUrl(url);","handlingStrategy":"validation","validationCode":"// validate before calling the provider\nfunction buildYouratorUrl(input) {\n  const raw = String(input ?? '').trim().replace(/^[\"']|[\"']$/g, '');\n  const url = /^https?:\\/\\//i.test(raw) ? raw : `https://${raw}`;\n  new URL(url); // throws early with a clear message if still malformed\n  return url;\n}","typeGuard":"function isParsableUrl(s) {\n  try { new URL(s); return true; } catch { return false; }\n}","tryCatchPattern":"try {\n  await scanYourator(entry);\n} catch (e) {\n  if (e.message.startsWith('yourator: invalid URL')) {\n    console.warn(`Fix the configured URL (add scheme, encode spaces): ${e.message}`);\n  } else throw e;\n}","preventionTips":["Store Yourator URLs in portals.yml as full absolute https:// URLs","Trim and strip quotes from config strings before URL construction","Avoid hand-building URLs by concatenation; use URL/URLSearchParams","Encode or reject path segments containing spaces or illegal characters"],"tags":["url","validation","yourator","scraper"],"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"}