santifer/career-ops · error · Error
wttj: invalid URL
Error message
wttj: invalid URL: ${url} What it means
wttj's assertHost pins a URL to an expected HTTPS host. If the URL cannot be parsed by the URL constructor at all (malformed input), it throws 'invalid URL' before any protocol/host checks. This is the provider's first line of URL validation.
Solutions
- Print/inspect the offending url string from the error message and fix its syntax
- Add the https:// scheme if it is missing
- Validate careers_url values in config before loading the provider
Example fix
// before const url = 'apply.wttj.io/acme/jobs'; // after const url = 'https://apply.wttj.io/acme/jobs';
Defensive patterns
Strategy: validation
Validate before calling
function isParseableUrl(u) { try { new URL(u); return true; } catch { return false; } }
if (!isParseableUrl(entry.careers_url)) throw new Error(`bad careers_url: ${entry.careers_url}`); Type guard
const isParseableUrl = (u) => { try { new URL(u); return typeof u === 'string' && u.length > 0; } catch { return false; } }; Try / catch
try { return wttjFetch(url); } catch (e) { if (e.message.startsWith('wttj: invalid URL')) { console.error(`Malformed URL in config: ${e.message}`); return null; } throw e; } Prevention
- Validate all configured URLs with new URL() at config load time
- Never build URLs by raw string concatenation without encoding
- Require an explicit https:// scheme in config values
When it happens
Trigger: assertHost called with a malformed string — missing scheme, spaces, unescaped characters, or a non-URL value passed where a URL is expected.
Common situations: A careers_url in config with a typo or missing protocol ('apply.wttj.io/jobs'); a truncated URL copied from a document; an interpolated URL built from an empty slug.
Understand the failure class
Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.
Related errors
- workable: URL must use HTTPS
- wttj: URL must use HTTPS
- 4dayweek: untrusted hostname
- a16z-speedrun-talent: invalid URL
- a16z-speedrun-talent: untrusted hostname
AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16).
Data as JSON: /api/errors/6de7395a9a37a849.
Report an issue: GitHub.
Appendix: source
Thrown at providers/wttj.mjs:63
const INDEX = 'wttj_jobs_production_en';
const DEFAULT_MAX_HITS = 100;
const MAX_HITS_CAP = 200;
// An unfiltered keyword query matches a large slice of a global board — "product
// manager" alone returns ~14k hits — so Algolia's own relevance ranking, not the
// scanner's filters, decides which 200 are seen. A server-side `filters`
// expression cuts the result set to something a single request can actually
// exhaust (e.g. product-management + France + full_time is ~450), so the cap is
// raised to Algolia's per-request ceiling for this index when one is configured.
const FILTERED_MAX_HITS_CAP = 1000;
const FILTERS_MAX_LEN = 1000;
/** Pin a URL to an expected https host. */
function assertHost(url, host, label) {
let parsed;
try {
parsed = new URL(url);
} catch {
throw new Error(`wttj: invalid URL: ${url}`);
}
if (parsed.protocol !== 'https:') throw new Error(`wttj: URL must use HTTPS: ${url}`);
if (parsed.hostname !== host.toLowerCase()) {
throw new Error(`wttj: untrusted ${label} hostname "${parsed.hostname}" — must be ${host}`);
}
return url;
}
/**
* Parse the `window.env = {...}` payload served by /api/env and extract the
* Algolia application id + client search key.
* @param {string} text
* @returns {{ appId: string, apiKey: string }}
*/
export function parseEnvPayload(text) {
const start = text.indexOf('{');
const end = text.lastIndexOf('}');
if (start === -1 || end <= start) throw new Error('wttj: /api/env payload has no JSON object');View on GitHub (pinned to aac998c7ed)