santifer/career-ops · error · Error
refusing to archive restricted destination
Error message
refusing to archive restricted destination: ${preGuard.reason} What it means
archiveUrl performs a pre-navigation safety check with rejectPrivateOrInvalid(url) before launching Playwright, refusing destinations that are private/internal or otherwise invalid (localhost, private IP ranges, non-http schemes, malformed URLs). This is an SSRF-style guard: an obviously-internal target must never reach the browser at all. The thrown message embeds the guard's specific reason.
Solutions
- Use the public, internet-reachable posting URL (e.g. the https:// boards.greenhouse.io/... or jobs.lever.co/... link) instead of a localhost or internal address.
- Inspect preGuard.reason (print the error) to see which rule fired — invalid URL vs private host — and fix the input accordingly.
- Validate/normalize the URL before calling: new URL(raw), require https: protocol, and confirm the host resolves publicly.
- If you legitimately need to archive an internal page, this function is not the tool — use Playwright directly outside this guarded path.
Example fix
// before
await archiveUrl('http://localhost:8080/jobs/senior-eng');
// after
const url = new URL('https://jobs.lever.co/acme/senior-eng');
if (url.protocol === 'https:' && !/^localhost$|^(10|127)\.|192\.168\./.test(url.hostname)) {
await archiveUrl(url.href);
} Defensive patterns
Strategy: validation
Validate before calling
function isPublicHttpUrl(raw) {
try {
const u = new URL(raw);
if (u.protocol !== 'https:' && u.protocol !== 'http:') return false;
if (/^(localhost|127\.|10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(u.hostname)) return false;
return true;
} catch { return false; }
}
if (!isPublicHttpUrl(url)) throw new Error(`not a public URL: ${url}`); Type guard
const isSafeDestination = (raw) => { try { const u = new URL(raw); return /^https?:$/.test(u.protocol) && !isPrivateHostname(u.hostname); } catch { return false; } }; Try / catch
try {
await archiveUrl(url);
} catch (err) {
if (err.message.startsWith('refusing to archive restricted destination:')) {
console.error(`Skipping ${url}: ${err.message.split(': ').pop()} (not a public posting URL?)`);
// mark the pipeline entry as needs-manual-review instead of retrying
} else throw err;
} Prevention
- Only archive public https:// posting URLs (Greenhouse/Lever/Ashby/Workday boards).
- Never test the archiver against localhost or staging — use the production board URL.
- Parse and normalize URLs before calling; reject non-http(s) schemes early.
- Read the embedded reason in the message — it names the exact guard rule that fired.
When it happens
Trigger: Passing http://localhost:3000/jobs/123, a private-network address (192.168.x.x, 10.x.x.x, 127.0.0.1), a file:// or other non-public-scheme URL, an empty or malformed string, or a URL pasted from an internal tool into archiveUrl.
Common situations: Testing the archiver against a local dev server or a staging host on an internal network; a pipeline entry containing a truncated or typo'd URL; accidentally archiving an admin/intranet posting URL; copy-pasting a URL from a local ATS instance.
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
- Access denied: Localhost or internal domain target detected.
- agentic-jobs: untrusted hostname
- eightfold: untrusted hostname
- landingjobs: untrusted hostname
- larajobs: untrusted hostname
AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16).
Data as JSON: /api/errors/9928ffc8581a53ce.
Report an issue: GitHub.
Appendix: source
Thrown at archive-posting.mjs:326
try {
await validateUrlSecurity(requestUrl);
return route.continue();
} catch (err) {
console.warn(` Blocked request to restricted destination (DNS): ${requestUrl} - ${err.message}`);
return route.abort('blockedbyclient');
}
});
}
export async function archiveUrl(browser, url, { company: companyHint, role: roleHint } = {}) {
console.log(`\n🔗 ${url}`);
// Refuse before launching any navigation, so an obviously-internal target
// never reaches Playwright at all.
const preGuard = rejectPrivateOrInvalid(url);
if (preGuard) {
throw new Error(`refusing to archive restricted destination: ${preGuard.reason}`);
}
const context = await browser.newContext();
await installEgressGuard(context);
const page = await context.newPage();
try {
const response = await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 30000 });
const httpStatus = response?.status() ?? 0;
// Re-check where we actually landed. The route guard already inspects every
// redirect hop, so this is defence-in-depth: a first-hop-only check is the
// classic miss here, and asserting on the settled URL costs nothing.
const landedUrl = page.url();
const postGuard = rejectPrivateOrInvalid(landedUrl);
if (postGuard) {
throw new Error(`refusing to archive restricted destination after redirect: ${postGuard.reason}`);
}View on GitHub (pinned to aac998c7ed)