santifer/career-ops · error
careerviet: untrusted hostname
Error message
careerviet: untrusted hostname "${parsed.hostname}" — must be ${TRUSTED_HOST} What it means
assertCareerVietUrl throws this when the URL is valid https but its hostname does not exactly equal the provider's single TRUSTED_HOST constant ('www.careerviet.vn'). Unlike per-tenant providers, CareerViet has exactly one legitimate origin, so the SSRF guard uses a strict equality check; any other hostname is rejected before fetching.
Solutions
- Set the URL host to exactly the trusted host named in the error (e.g. 'https://www.careerviet.vn').
- Do not rely on redirects — the guard checks the literal hostname, so 'https://careerviet.vn' must be rewritten, not redirected.
- Verify the entry is actually a CareerViet posting; unrelated boards belong under a different provider.
- Check for lookalike-character typos in the hostname.
Example fix
# before careers_url: https://careerviet.vn/viec-lam # after careers_url: https://www.careerviet.vn/viec-lam
Defensive patterns
Strategy: validation
Validate before calling
const TRUSTED_HOST = 'www.careerviet.vn';
function isTrustedCareerVietHost(u) {
try { return new URL(u).hostname === TRUSTED_HOST; } catch { return false; }
}
if (!isTrustedCareerVietHost(entry.careers_url)) throw new Error(`careerviet entry host must be ${TRUSTED_HOST}`); Type guard
function isTrustedHost(hostname) { return hostname === 'www.careerviet.vn'; } Try / catch
try {
await provider.fetch(entry, ctx);
} catch (err) {
if (String(err.message).startsWith('careerviet: untrusted hostname')) {
console.warn(`Skipping entry: hostname is not ${'www.careerviet.vn'} — check portals.yml`);
return null;
}
throw err;
} Prevention
- Use the exact trusted host including the 'www.' prefix — the guard is strict equality, not a suffix match.
- Never count on redirects from careerviet.vn to www.careerviet.vn; the guard rejects pre-redirect hosts.
- Validate hostnames in a startup config check against the provider's TRUSTED_HOST constant.
- Watch for lookalike-character typos when editing the hostname by hand.
When it happens
Trigger: A request URL reaching assertCareerVietUrl with hostname 'careerviet.vn' (missing www), a mirror/clone domain, a typo ('careerivet.vn'), or any unrelated host configured under the careerviet entry.
Common situations: Omitting the 'www.' prefix; redirecting the entry at a regional or spoofed mirror; pasting the company's own site instead of the CareerViet board; typos introduced during config editing.
Related errors
- breezy: untrusted hostname
- builtin: untrusted hostname
- arbeitnow: untrusted hostname
- ashby: untrusted hostname
- bamboohr: untrusted hostname
AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16).
Data as JSON: /api/errors/d7f8862257a47b5d.
Report an issue: GitHub.
Appendix: source
Thrown at providers/careerviet.mjs:110
const UPDATED_DATE_RE = /Cập nhật(?:<!--[\s\S]*?-->)?\s*:?\s*(?:<\/span>)?\s*<time>([\d/-]+)<\/time>/i;
/** @param {any} ctx @param {number} ms */
function sleep(ctx, ms) {
if (typeof ctx?.sleep === 'function') return ctx.sleep(ms);
return new Promise((r) => setTimeout(r, ms));
}
/** @param {string} url */
function assertCareerVietUrl(url) {
let parsed;
try {
parsed = new URL(url);
} catch {
throw new Error(`careerviet: invalid URL: ${url}`);
}
if (parsed.protocol !== 'https:') throw new Error(`careerviet: URL must use HTTPS: ${url}`);
if (parsed.hostname !== TRUSTED_HOST) {
throw new Error(`careerviet: untrusted hostname "${parsed.hostname}" — must be ${TRUSTED_HOST}`);
}
return url;
}
/**
* Collapse a markup fragment to its visible text.
* @param {string} fragment
* @returns {string}
*/
export function visibleText(fragment) {
return decodeEntities(
String(fragment ?? '')
.replace(/<!--[\s\S]*?-->/g, ' ')
.replace(/<[^>]+>/g, ' '),
)
.replace(/\s+/g, ' ')
.trim();
}View on GitHub (pinned to aac998c7ed)