santifer/career-ops · error · Error

torre: untrusted hostname

Error message

torre: untrusted hostname "${parsed.hostname}" — must be ${TRUSTED_API_HOST}

What it means

The torre provider restricts requests to a single trusted API host (search.torre.co). assertTorreUrl parses the URL and compares parsed.hostname against TRUSTED_API_HOST; any other hostname is rejected. This prevents the provider from being pointed at arbitrary hosts (SSRF/injection defense) — even a valid https URL to a look-alike domain is refused.

Solutions

  1. Set the careers_url host to exactly https://search.torre.co (no www, no extra subdomains)
  2. Use the provider default endpoint instead of overriding careers_url — the torre provider builds its own POST https://search.torre.co/opportunities/_search URL
  3. Check for typos or trailing characters in the configured hostname (e.g. .co0, a space, a port suffix)
  4. If you genuinely need another host, it requires a code change to TRUSTED_API_HOST in providers/torre.mjs — do not attempt to work around it in config

Example fix

// before
careers_url: https://www.torre.co/opportunities/_search
// after
careers_url: https://search.torre.co/opportunities/_search
Defensive patterns

Strategy: validation

Validate before calling

const TRUSTED_API_HOST = 'search.torre.co';
function isTrustedTorreUrl(url) {
  try {
    const parsed = new URL(url);
    return parsed.protocol === 'https:' && parsed.hostname === TRUSTED_API_HOST;
  } catch { return false; }
}

Type guard

const isTorreApiUrl = (u) => { try { return new URL(u).hostname === 'search.torre.co'; } catch { return false; } };

Try / catch

try {
  await torreProvider.fetch(entry);
} catch (err) {
  if (err.message.includes('untrusted hostname')) {
    const host = new URL(entry.careers_url).hostname;
    console.error(`${entry.name}: host "${host}" not allowed for torre — use search.torre.co`);
    return;
  }
  throw err;
}

Prevention

When it happens

Trigger: A portals.yml entry for provider torre carries a careers_url whose hostname is not exactly 'search.torre.co' — e.g. 'https://api.torre.co/...', 'https://search.torre.co.evil.example/...', 'https://www.torre.co/...', or a typo'd host like 'search.torre.co0'. The URL is well-formed and https, so only the hostname check fires.

Common situations: Typos in the config host, copying the posting permalink host (torre.ai) instead of the API host (search.torre.co), subdomain confusion (www. prefix), or an attacker-influenced value reaching the URL field (the check exists precisely for this).

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


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

Appendix: source

Thrown at providers/torre.mjs:94

  'potential-to-develop',
  '1-plus-year',
  '2-plus-years',
  '3-plus-years',
  '5-plus-years',
]);
const DEFAULT_EXPERIENCE = '1-plus-year';

/** @param {string} url */
function assertTorreUrl(url) {
  let parsed;
  try {
    parsed = new URL(url);
  } catch {
    throw new Error(`torre: invalid URL: ${url}`);
  }
  if (parsed.protocol !== 'https:') throw new Error(`torre: URL must use HTTPS: ${url}`);
  if (parsed.hostname !== TRUSTED_API_HOST) {
    throw new Error(`torre: untrusted hostname "${parsed.hostname}" — must be ${TRUSTED_API_HOST}`);
  }
  return url;
}

/**
 * Build the search body from the portal entry. Only filters proven to affect
 * `total` are emitted — see the header note. Exported for tests.
 *
 * @param {any} entry
 * @returns {object}
 */
export function buildTorreQuery(entry) {
  /** @type {Record<string, unknown>} */
  const body = {};

  const search = typeof entry?.search === 'string' ? entry.search.trim() : '';
  if (search) {
    // `experience` is mandatory here — omitting it is a hard 500, so it is

View on GitHub (pinned to aac998c7ed)