santifer/career-ops · error · Error

the published index exceeds

Error message

the published index exceeds ${MAX_INDEX_BYTES} bytes (${declared}): ${url}

What it means

downloadAsset throws this when the response's declared content-length header exceeds MAX_INDEX_BYTES. The plugin caps the published index size because nothing on the API path should be that large; a bigger declared body suggests the wrong asset, a hijacked/misconfigured endpoint, or an attack.

Solutions

  1. Verify the asset URL points at the official published index, not an unrelated file.
  2. Check the actual size of the upstream index; if the format legitimately grew, update MAX_INDEX_BYTES in the plugin.
  3. Re-run against the default endpoint (unset custom base/asset overrides).

Example fix

null
Defensive patterns

Strategy: validation

Validate before calling

const head = await fetch(url, { method: 'HEAD' });
const len = Number(head.headers.get('content-length'));
if (Number.isFinite(len) && len > MAX_INDEX_BYTES) throw new Error(`upstream index too large: ${len} bytes`);

Try / catch

try {
  await installIndex();
} catch (e) {
  if (e.message.includes('exceeds') && e.message.includes('bytes')) {
    console.error('Download exceeds the plugin size cap; verify you are pointed at the official index.');
  }
}

Prevention

When it happens

Trigger: downloadAsset reads res.headers.get('content-length'); Number(declared) is finite and > MAX_INDEX_BYTES. Happens immediately, before any body bytes are read.

Common situations: Pointing H1B_API_BASE or the asset URL at the wrong host/file; the upstream project republishes a much larger index format; a malicious mirror serving an oversized payload.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


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

Appendix: source

Thrown at plugins/h1b-sponsor/install-h1b-index.mjs:149

    ? null
    : String(doc.version).slice(0, 64);
  return { filename, sha256, version };
}

/**
 * Stream the asset to `tmpFile`, hashing as it goes, and return the digest.
 *
 * Streamed rather than buffered: the body is millions of times the size of
 * anything else this plugin reads, and readBoundedText's 1 MiB ceiling exists
 * precisely because nothing on the API path should ever be this big. Hashing
 * during the write means the file is never read a second time to verify it.
 */
async function downloadAsset(fetchImpl, url, tmpFile) {
  return fetchImpl(url, { timeoutMs: ASSET_TIMEOUT_MS }, async res => {
    if (res.status !== 200) throw new Error(`could not download the index (HTTP ${res.status}): ${url}`);
    const declared = Number(res.headers?.get?.('content-length'));
    if (Number.isFinite(declared) && declared > MAX_INDEX_BYTES) {
      throw new Error(`the published index exceeds ${MAX_INDEX_BYTES} bytes (${declared}): ${url}`);
    }
    if (!res.body || typeof res.body.getReader !== 'function') {
      throw new Error(`the index response carried no readable body: ${url}`);
    }

    const hash = createHash('sha256');
    const out = createWriteStream(tmpFile);
    // A write failure (disk full, an unwritable target) arrives as an 'error'
    // event on the stream, and an EventEmitter error with no listener is an
    // uncaughtException: the CLI died on a stack trace instead of returning
    // the envelope, and the cleanup that removes the partial .tmp file never
    // ran. Recording the error here makes the crash impossible; the checks
    // below turn it into the ordinary failure it is. once(out, 'drain') needs
    // no extra wiring, it already rejects when 'error' fires mid-wait.
    let writeError = null;
    out.on('error', err => { writeError = err; });
    const reader = res.body.getReader();
    let total = 0;

View on GitHub (pinned to aac998c7ed)