santifer/career-ops · error · Error

torre: invalid URL: ${url}

Error message

torre: invalid URL: ${url}

What it means

assertTorreUrl validates every URL the Torre provider will touch: it must parse as a URL, be HTTPS, and its hostname must equal the trusted Torre API host. This error is thrown when the string cannot be parsed by new URL() at all — missing scheme, spaces, malformed syntax — so no protocol/host checks can even run.

Source

Thrown at providers/torre.mjs:90

// Values the API accepts for the required `skill/role.experience` companion,
// confirmed live; anything else is rejected server-side. Every one returns the
// same result set, so the default is arbitrary among them.
const EXPERIENCE_LEVELS = new Set([
  '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 = {};

View on GitHub (pinned to 1696bec4d0)

Solutions

  1. Prefix the URL with https:// if only a hostname or path was given.
  2. Inspect the raw string (the message echoes it) for typos, spaces, or mangled YAML quoting and fix it at the source.
  3. Ensure the value is an actual string — check for null/undefined config fields that interpolate into 'undefined'.
  4. If the URL is user/third-party supplied, validate or normalize it before handing it to the Torre provider.

Example fix

// before
assertTorreUrl('torre.ai/jobs');
// Error: torre: invalid URL: torre.ai/jobs
// after
assertTorreUrl('https://torre.ai/jobs');
Defensive patterns

Strategy: validation

Validate before calling

function isParseableUrl(url) {
  if (typeof url !== 'string' || !url.trim()) return false;
  try { new URL(url); return true; } catch { return false; }
}
if (!isParseableUrl(torreUrl)) torreUrl = 'https://' + torreUrl; // normalize bare hosts

Type guard

function isAbsoluteHttpUrl(v) {
  if (typeof v !== 'string') return false;
  try { const u = new URL(v); return u.protocol === 'http:' || u.protocol === 'https:'; }
  catch { return false; }
}

Try / catch

try {
  assertTorreUrl(raw);
} catch (err) {
  if (String(err.message).startsWith('torre: invalid URL:')) {
    console.error(`Malformed URL in config, fix the scheme/syntax: ${err.message}`);
  } else throw err;
}

Prevention

When it happens

Trigger: Calling assertTorreUrl with a bare hostname like 'torre.ai', a relative path '/jobs', an empty/whitespace string, a URL with invalid characters, or a non-string coerced badly; config entries with unquoted YAML values that lose scheme or get mangled.

Common situations: Config value written without 'https://' because the author assumed a default; YAML special characters breaking the value; a template placeholder left unfilled; pasting a link from a messaging app that stripped the scheme.

Related errors


AI-assisted analysis of santifer/career-ops@1696bec4d0 (2026-09-01). Data as JSON: /api/errors/7ed4798d17b679ff. Report an issue: GitHub.