{"record":{"id":"9a43fd1b259276a1","repo":"santifer/career-ops","slug":"careerviet-invalid-url-url","errorCode":null,"errorMessage":"careerviet: invalid URL: ${url}","messagePattern":"careerviet: invalid URL: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"providers/careerviet.mjs","lineNumber":106,"sourceCode":" * The \"Cập nhật\" (updated) date sits in its own <li>, sibling to \"Hạn nộp\"\n * (deadline) inside the same .time block — the label text is what tells them\n * apart; both wrap their <time> the same way.\n */\nconst UPDATED_DATE_RE = /Cập nhật(?:<!--[\\s\\S]*?-->)?\\s*:?\\s*(?:<\\/span>)?\\s*<time>([\\d/-]+)<\\/time>/i;\n\n/** @param {any} ctx @param {number} ms */\nfunction sleep(ctx, ms) {\n  if (typeof ctx?.sleep === 'function') return ctx.sleep(ms);\n  return new Promise((r) => setTimeout(r, ms));\n}\n\n/** @param {string} url */\nfunction assertCareerVietUrl(url) {\n  let parsed;\n  try {\n    parsed = new URL(url);\n  } catch {\n    throw new Error(`careerviet: invalid URL: ${url}`);\n  }\n  if (parsed.protocol !== 'https:') throw new Error(`careerviet: URL must use HTTPS: ${url}`);\n  if (parsed.hostname !== TRUSTED_HOST) {\n    throw new Error(`careerviet: untrusted hostname \"${parsed.hostname}\" — must be ${TRUSTED_HOST}`);\n  }\n  return url;\n}\n\n/**\n * Collapse a markup fragment to its visible text.\n * @param {string} fragment\n * @returns {string}\n */\nexport function visibleText(fragment) {\n  return decodeEntities(\n    String(fragment ?? '')\n      .replace(/<!--[\\s\\S]*?-->/g, ' ')\n      .replace(/<[^>]+>/g, ' '),","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/providers/careerviet.mjs#L88-L124","documentation":"The CareerViet provider's assertCareerVietUrl guard throws this when the URL string cannot be parsed by new URL(). Every CareerViet request URL passes through this SSRF guard before fetching; a value that is not a syntactically valid absolute URL is rejected before any network I/O.","triggerScenarios":"A request URL for careerviet_vn composed from a malformed config value or a broken template interpolation: missing scheme, 'https:/careerviet.vn' (single slash), embedded whitespace, or an empty origin segment reaching assertCareerVietUrl.","commonSituations":"Hand-edited portals.yml entry with a typo in the URL; environment-variable or templating substitution that came out empty; copying a URL with an invisible trailing character from a document.","solutions":["Correct the URL in the careerviet portals entry to the full absolute form 'https://www.capabilities'... i.e. 'https://www.careerviet.vn/...'.","Reproduce the SyntaxError locally with `new URL(value)` to see exactly which character breaks parsing.","Trim whitespace/control characters and confirm the scheme separator is '://'.","If the URL is composed in code, log the intermediate parts to find the empty/undefined segment."],"exampleFix":"// before\nconst url = `https://${undefined}/viec-lam`;\n// after\nconst base = 'https://www.careerviet.vn';\nconst url = `${base}/viec-lam`;","handlingStrategy":"validation","validationCode":"function isValidUrl(u) {\n  try { new URL(u); return true; } catch { return false; }\n}\nif (!isValidUrl(entry.careers_url)) throw new Error(`careerviet entry URL unparseable: ${entry.careers_url}`);","typeGuard":"function isNonEmptyString(v) { return typeof v === 'string' && v.trim().length > 0; }","tryCatchPattern":"try {\n  await provider.fetch(entry, ctx);\n} catch (err) {\n  if (String(err.message).startsWith('careerviet: invalid URL')) {\n    console.warn(`Skipping careerviet entry: malformed URL — fix portals.yml`);\n    return null;\n  }\n  throw err;\n}","preventionTips":["Use full absolute https:// URLs in the careerviet portals entry.","Validate all URLs with new URL() in a startup config check.","Trim whitespace/BOM from config values before use.","Avoid building URLs by interpolating variables that may be undefined or empty."],"tags":["url","validation","ssrf-guard","config"],"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"}