{"record":{"id":"a21261888fc2e568","repo":"santifer/career-ops","slug":"eightfold-invalid-url-url","errorCode":null,"errorMessage":"eightfold: invalid URL: ${url}","messagePattern":"eightfold: invalid URL: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"providers/eightfold.mjs","lineNumber":69,"sourceCode":"const MAX_PAGES_CAP = 1000;\n// Same-host pacing between pages inside one tenant's own pagination loop.\n// Eightfold's edge rate-limits bursts, and a 616-job board is 62 requests.\nconst INTER_PAGE_DELAY_MS = 150;\n\nconst RETRY_POLICY = { retries: 3, baseDelayMs: 500, maxDelayMs: 8_000 };\n\n/**\n * SSRF guard — every request URL passes through here before it is fetched.\n *\n * @param {string} url\n * @returns {string} the same URL, when it is a trusted Eightfold endpoint.\n */\nfunction assertEightfoldUrl(url) {\n  let parsed;\n  try {\n    parsed = new URL(url);\n  } catch {\n    throw new Error(`eightfold: invalid URL: ${url}`);\n  }\n  if (parsed.protocol !== 'https:') throw new Error(`eightfold: URL must use HTTPS: ${url}`);\n  if (!EIGHTFOLD_HOST_RE.test(parsed.hostname)) {\n    throw new Error(`eightfold: untrusted hostname \"${parsed.hostname}\" — must match *.eightfold.ai`);\n  }\n  return url;\n}\n\n/** @param {number} ms @param {any} ctx */\nfunction sleep(ms, ctx) {\n  if (typeof ctx?.sleep === 'function') return ctx.sleep(ms);\n  return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Eightfold reports timestamps as epoch SECONDS (`t_create`, `t_update`), not\n * the ISO strings every other provider gets. Converted here; anything\n * non-finite or non-positive is dropped rather than guessed at.","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/santifer/career-ops/blob/9b17a8ac97b398a496b38e423ae24e433b43254f/providers/eightfold.mjs#L51-L87","documentation":"Thrown by eightfold's assertEightfoldUrl when new URL() cannot parse the value. It is defense-in-depth: in fetch() the URL is always built by buildApiUrl from a resolveTenant-validated host, so it is always a well-formed https URL and this branch is unreachable through normal use. Reachable only via a direct assertEightfoldUrl call.","triggerScenarios":"assertEightfoldUrl is called directly with a non-URL value. fetch() constructs the URL via buildApiUrl(tenant,...) where tenant.host already matched EIGHTFOLD_HOST_RE, so no entry config produces a malformed URL here.","commonSituations":"A unit test or custom integration calling assertEightfoldUrl on raw input. Production scans do not reach this branch.","solutions":["For direct callers, validate the value parses as a URL first.","For normal fetch() use, no action — buildApiUrl always yields a valid URL.","Treat a production hit as a signal that the URL is no longer built solely via buildApiUrl."],"exampleFix":"// before — direct call on raw input\nassertEightfoldUrl(maybeUrl);\n\n// after — validate first\ntry { new URL(maybeUrl); } catch { /* not a URL, skip */ }","handlingStrategy":"validation","validationCode":"// Through fetch() unreachable (URL built via buildApiUrl from a validated tenant). For a direct call:\nfunction isParseableUrl(u) { try { new URL(u); return true; } catch { return false; } }","typeGuard":"function isParseableUrl(u) {\n  if (typeof u !== 'string' || !u) return false;\n  try { new URL(u); return true; } catch { return false; }\n}","tryCatchPattern":"try { assertEightfoldUrl(url); }\ncatch (e) {\n  if (/^eightfold: invalid URL/.test(e.message)) { /* input wasn't a URL — skip */ }\n  else throw e;\n}","preventionTips":["No action for normal scans — buildApiUrl always yields a valid URL.","For direct calls, pre-parse with new URL().","Treat a production hit as a refactor signal."],"tags":["url-validation","eightfold","ssrf","defense-in-depth"],"backgroundTag":null,"analyzedSha":"9b17a8ac97b398a496b38e423ae24e433b43254f","analyzedAt":"2026-08-13T00:48:39.135Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}