santifer/career-ops · error

glints: invalid URL

Error message

glints: invalid URL: ${url}

What it means

assertGlintsUrl validates URLs for the Glints provider. When the input string cannot be parsed by new URL() (missing scheme, malformed characters, etc.), it throws this error — the first gate before the HTTPS and hostname-allowlist checks. ALLOWED_GLINTS_HOSTS covers glints.com, www.glints.com, and glints.id.

Solutions

  1. Make the value a full absolute URL with scheme, e.g. https://glints.com/api/v2-alc/graphql
  2. Trim whitespace/smart quotes and quote the value in YAML; resolve any ${...} placeholders before runtime
  3. Sanity-check with `new URL(value)` locally before putting it in config
  4. Remove a custom api value if you meant to use the default endpoint (https://glints.com/api/v2-alc/graphql)

Example fix

// before
api: glints.com/api/v2-alc/graphql
// after
api: https://glints.com/api/v2-alc/graphql
Defensive patterns

Strategy: validation

Validate before calling

function isValidAbsoluteUrl(s) { try { new URL(s); return true; } catch { return false; } }
if (entry.api && !isValidAbsoluteUrl(entry.api)) throw new Error(`glints entry ${entry.name}: api is not a valid absolute URL`);

Type guard

function isParseableUrl(v) { return typeof v === 'string' && (() => { try { new URL(v); return true; } catch { return false; } })(); }

Try / catch

try {
  assertGlintsUrl(url);
} catch (e) {
  if (String(e.message).includes('invalid URL')) {
    console.error(`${url} is not parseable — missing https:// scheme or malformed characters`);
    return null;
  }
  throw e;
}

Prevention

When it happens

Trigger: A glints portal entry (e.g. a custom api endpoint URL) contains a string that is not a valid absolute URL — 'glints.com/api/v2-alc/graphql' without scheme, a URL with spaces, or an unsubstituted placeholder — and is passed to assertGlintsUrl.

Common situations: Hand-editing portals.yml and dropping https://; YAML multi-line folding corrupting the URL; environment-variable placeholders (${GLINTS_API}) left unresolved in the config value.

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/00f65e302501e9ed. Report an issue: GitHub.

Appendix: source

Thrown at providers/glints.mjs:75

        salaryMode
        maxAmount
        minAmount
        CurrencyCode
      }
      createdAt
    }
    expInfo
    hasMore
  }
}`;

/** @param {string} url */
function assertGlintsUrl(url) {
  let parsed;
  try {
    parsed = new URL(url);
  } catch {
    throw new Error(`glints: invalid URL: ${url}`);
  }
  if (parsed.protocol !== 'https:') throw new Error(`glints: URL must use HTTPS: ${url}`);
  if (!ALLOWED_GLINTS_HOSTS.has(parsed.hostname))
    throw new Error(`glints: untrusted hostname "${parsed.hostname}" — must be one of: ${[...ALLOWED_GLINTS_HOSTS].join(', ')}`);
  return url;
}

// NaN-safe Date.parse
function toEpochMs(value) {
  if (!value) return undefined;
  const parsed = Date.parse(value);
  return Number.isNaN(parsed) ? undefined : parsed;
}

/**
 * Derive the job detail base URL from the API hostname.
 * @param {string} apiUrl
 * @returns {string}

View on GitHub (pinned to aac998c7ed)