santifer/career-ops · error · Error
senjob: untrusted hostname
Error message
senjob: untrusted hostname "${parsed.hostname}" — must be ${TRUSTED_HOST} What it means
This error is thrown by assertSenjobUrl in providers/senjob.mjs when a URL passes HTTPS validation but its hostname is not the single trusted host 'senjob.com'. The provider only fetches from its own list URL (https://senjob.com/offres-d-emploi.php), so any other hostname is treated as untrusted input and rejected to prevent fetching or parsing arbitrary pages. It is an SSRF/host-pinning guard, not a network failure.
Solutions
- Use the exact host senjob.com (no www, no alternate TLD) in any URL passed to the provider
- Prefer the provider's built-in buildListUrl(page) instead of hand-constructing list URLs
- If a mirror host must be supported, update the TRUSTED_HOST constant or extend the hostname check in providers/senjob.mjs
- Check for an accidental www. prefix or trailing proxy host in portals.yml
Example fix
// before const url = 'https://www.senjob.com/offres-d-emploi.php'; // after const url = 'https://senjob.com/offres-d-emploi.php'; // exact TRUSTED_HOST
Defensive patterns
Strategy: validation
Validate before calling
function isTrustedSenjobUrl(url) {
try {
const u = new URL(url);
return u.protocol === 'https:' && u.hostname === 'senjob.com';
} catch { return false; }
}
if (!isTrustedSenjobUrl(myUrl)) throw new Error('refusing to fetch non-senjob.com URL'); Type guard
const isSenjobUrl = (url) => {
try { return new URL(url).hostname === 'senjob.com'; } catch { return false; }
}; Try / catch
try {
await senjobProvider.fetch(entry, ctx);
} catch (e) {
if (String(e.message).includes('untrusted hostname')) {
console.error(`Config error: ${entry.name} must point at senjob.com, got: ${entry.careers_url ?? entry.api}`);
} else throw e;
} Prevention
- Always configure senjob boards with the exact host senjob.com (no www)
- Use the provider's buildListUrl(page) instead of constructing URLs by hand
- Validate portals entries at startup with a hostname allowlist check
- Never feed externally supplied URLs straight into the provider — derive them from config
When it happens
Trigger: Calling senjob fetch with a portals entry or override whose URL points at a different host (e.g. www.senjob.com, senjob.net, a mirror, or a malicious link injected via config); any code path that bypasses buildListUrl and supplies its own URL to assertSenjobUrl with a foreign hostname.
Common situations: Configuring the senjob board with a careers_url of 'https://www.senjob.com/...' (the www prefix fails the exact-match check); typos in the host; trying to reuse the provider for a different Senegalese board like emploisenegal.com; redirect targets being followed manually.
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
- smartrecruiters: untrusted hostname
- solidjobs: untrusted hostname
- workable: untrusted hostname
- collage: untrusted hostname
- comeet: URL path must be the careers-api endpoint
AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16).
Data as JSON: /api/errors/84c91586037dc99d.
Report an issue: GitHub.
Appendix: source
Thrown at providers/senjob.mjs:81
const HIDDEN_ISO_DATE_RE = /display:\s*none;?\s*"?>\s*(\d{4}-\d{2}-\d{2})\s*</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 assertSenjobUrl(url) {
let parsed;
try {
parsed = new URL(url);
} catch {
throw new Error(`senjob: invalid URL: ${url}`);
}
if (parsed.protocol !== 'https:') throw new Error(`senjob: URL must use HTTPS: ${url}`);
if (parsed.hostname !== TRUSTED_HOST) {
throw new Error(`senjob: untrusted hostname "${parsed.hostname}" — must be ${TRUSTED_HOST}`);
}
return url;
}
/**
* Collapse a markup fragment to its visible text.
* Comments are stripped FIRST: the anchor bodies carry `<!-- d ico postulez -->`
* between the title and a spacer image, and a naive tag strip would leave the
* comment body sitting inside the title.
* @param {string} fragment
* @returns {string}
*/
export function visibleText(fragment) {
return decodeEntities(
String(fragment ?? '')
.replace(/<!--[\s\S]*?-->/g, ' ')
.replace(/<[^>]+>/g, ' '),
)View on GitHub (pinned to aac998c7ed)