santifer/career-ops · error · Error
4dayweek: untrusted hostname
Error message
4dayweek: untrusted hostname "${parsed.hostname}" — must be ${TRUSTED_HOST} What it means
This error is thrown by assertFourDayUrl in providers/4dayweek.mjs when a URL passed to the 4dayweek provider parses successfully but its hostname does not exactly match the provider's single allowed TRUSTED_HOST. The provider only fetches from its own known feed host, so any other hostname is rejected as a guard against SSRF and misconfigured feed URLs. HTTPS is also enforced separately, but this specific throw fires only when the protocol check already passed and the hostname is wrong.
Solutions
- Check the URL's hostname and correct it to the exact TRUSTED_HOST value defined at the top of providers/4dayweek.mjs.
- If you intended a different host, that host is intentionally unsupported — remove the entry or point it at the official 4dayweek feed.
- Verify there is no stray path/port/subdomain confusion by printing new URL(url).hostname before calling the provider.
Example fix
// before
fetch4dayweek('https://mirror.example.com/feed?page=1')
// after
fetch4dayweek('https://4dayweek.com/feed?page=1') // exact TRUSTED_HOST Defensive patterns
Strategy: validation
Validate before calling
const u = new URL(url);
if (u.protocol !== 'https:' || u.hostname !== TRUSTED_HOST) {
throw new Error(`refusing to fetch: ${url} is not the trusted 4dayweek feed host`);
} Type guard
function isTrusted4dwUrl(url) {
try { const u = new URL(url); return u.protocol === 'https:' && u.hostname === TRUSTED_HOST; }
catch { return false; }
} Try / catch
try {
await fetch4dayweek(url);
} catch (e) {
if (String(e.message).startsWith('4dayweek: untrusted hostname')) {
console.error(`Config error: feed URL must point at ${TRUSTED_HOST}, got: ${url}`);
} else throw e;
} Prevention
- Keep feed URLs in one config constant rather than interpolating hostnames ad hoc.
- When copying provider configs, check that TRUSTED_HOST matches the new provider.
- Assert new URL(url).hostname against the expected host in config tests.
When it happens
Trigger: Calling the provider with a feed/entry URL whose parsed hostname !== TRUSTED_HOST (e.g. an http->https-correct URL pointing at a mirror domain, a typo like '4dayweek.io' instead of the exact trusted host, or a portals.yml careers_url that points at the company site rather than the feed host).
Common situations: A custom portals.yml entry with a wrong careers_url; a provider config copied from another provider whose TRUSTED_HOST differs; DNS or proxy rewrites changing the host; someone testing against a local/staging mirror of the feed.
Understand the failure class
Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.
Related errors
- a16z-speedrun-talent: untrusted hostname
- a16z-speedrun-talent: invalid URL
- a16z-speedrun-talent: URL must use HTTPS
- agentic-jobs: invalid URL
- agentic-jobs: untrusted hostname
AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16).
Data as JSON: /api/errors/ca065e2976f629b6.
Report an issue: GitHub.
Appendix: source
Thrown at providers/4dayweek.mjs:57
}
} catch {
// Ignore malformed URLs; another provider may still claim the entry.
}
}
return null;
}
/** @param {string} url */
function assertFourDayUrl(url) {
let parsed;
try {
parsed = new URL(url);
} catch {
throw new Error(`4dayweek: invalid URL: ${url}`);
}
if (parsed.protocol !== 'https:') throw new Error(`4dayweek: URL must use HTTPS: ${url}`);
if (parsed.hostname !== TRUSTED_HOST) {
throw new Error(`4dayweek: untrusted hostname "${parsed.hostname}" — must be ${TRUSTED_HOST}`);
}
return url;
}
/** Resolve the page cap: a positive integer `max_pages` on the entry, capped. */
function resolveMaxPages(entry) {
const v = entry?.max_pages;
if (Number.isInteger(v) && v > 0) return Math.min(v, MAX_PAGES_CAP);
return DEFAULT_MAX_PAGES;
}
// NaN-safe: posted is epoch SECONDS → ms; anything non-finite yields undefined.
function toEpochMs(seconds) {
return Number.isFinite(seconds) ? seconds * 1000 : undefined;
}
/**
* Normalize a single 4 Day Week job. Exported for unit tests.View on GitHub (pinned to aac998c7ed)