santifer/career-ops · error · Error

wttj: URL must use HTTPS

Error message

wttj: URL must use HTTPS: ${url}

What it means

assertHost requires the parsed URL to use the https: protocol; any other scheme (http:, ftp:, javascript:, etc.) throws this error. Combined with the hostname check, it guarantees the provider only ever fetches pinned HTTPS endpoints.

Solutions

  1. Change the scheme to https:// and retry
  2. Verify the endpoint actually serves HTTPS (all WTTJ public endpoints do)
  3. Fix the source config/entry rather than weakening the assertion

Example fix

// before
assertHost('http://www.wttj.fr/api/env', 'www.wttj.fr', 'env');
// after
assertHost('https://www.wttj.fr/api/env', 'www.wttj.fr', 'env');
Defensive patterns

Strategy: validation

Validate before calling

function isHttps(u) { try { return new URL(u).protocol === 'https:'; } catch { return false; } }
if (!isHttps(entry.careers_url)) throw new Error(`must be https: ${entry.careers_url}`);

Type guard

const isHttps = (u) => { try { return new URL(u).protocol === 'https:'; } catch { return false; } };

Try / catch

try { return await wttj.fetch(entry, ctx); } catch (e) { if (e.message.startsWith('wttj: URL must use HTTPS')) { console.warn(`Fix ${entry.name}: ${e.message}`); return []; } throw e; }

Prevention

When it happens

Trigger: assertHost called with a syntactically valid URL whose protocol !== 'https:', e.g. 'http://apply.wttj.io/acme'.

Common situations: Configured careers_url using plain HTTP; a URL built programmatically with a default 'http' scheme; a captured link downgraded to http.

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


AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16). Data as JSON: /api/errors/b1c27f7bca70b90d. Report an issue: GitHub.

Appendix: source

Thrown at providers/wttj.mjs:65

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');
  let env;
  try {

View on GitHub (pinned to aac998c7ed)