abhigyanpatwari/GitNexus · error · HttpEmbeddingError

Embedding endpoint returned empty response (${safeUrl(url)})

Error message

Embedding endpoint returned empty response (${safeUrl(url)})

What it means

An HttpEmbeddingError thrown in httpEmbedQuery as a defensive backstop when httpEmbedBatch returns an empty array for a single-text query. The inline comment marks it unreachable: an empty `data` array is now a cardinality mismatch (0 vectors for 1 text) rejected and retried inside httpEmbedBatch (error 125), so this branch is a guard against a future regression. If it fires, the in-loop cardinality check was bypassed.

Source

Thrown at gitnexus/src/core/embeddings/http-client.ts:663

  const url = `${config.baseUrl}/embeddings`;
  const items = await httpEmbedBatch(
    url,
    [text],
    config.model,
    config.apiKey,
    0,
    config.requestDimensions,
    requestOptions,
    config.maxAttempts,
    config.retryCapMs,
    config.minIntervalMs,
    config.timeoutMs,
  );
  // Defensive backstop like the `httpEmbed` one above: an empty `data` array is
  // now a cardinality mismatch (0 vectors for 1 text) rejected and retried
  // inside `httpEmbedBatch`, so this branch is unreachable in practice.
  if (!items.length) {
    throw new HttpEmbeddingError(`Embedding endpoint returned empty response (${safeUrl(url)})`);
  }

  const embedding = items[0].embedding;
  // Same dimension checks as httpEmbed — catch mismatches before they
  // reach the Kuzu FLOAT[N] cast in search queries.
  const expected = config.dimensions ?? DEFAULT_DIMS;
  if (embedding.length !== expected) {
    const hint = config.dimensions
      ? 'Update GITNEXUS_EMBEDDING_DIMS to match your model output.'
      : `Set GITNEXUS_EMBEDDING_DIMS=${embedding.length} to match your model output.`;
    throw new HttpEmbeddingError(
      `Embedding dimension mismatch: endpoint returned ${embedding.length}d vector, ` +
        `but expected ${expected}d. ${hint}`,
    );
  }
  return embedding;
};

View on GitHub (pinned to d540b00184)

Solutions

  1. Treat as an internal invariant violation: this branch is documented as unreachable.
  2. Reinstall/align gitnexus versions to ensure httpEmbedBatch's in-loop cardinality check is present.
  3. Report the occurrence with the safe URL from the message.
  4. Retry after a clean rebuild; fall back to a known-good release if it recurs.
Defensive patterns

Strategy: try-catch

Type guard

import { isHttpEmbeddingError } from 'gitnexus';
const isDefensiveEmpty = (e: unknown): boolean =>
  isHttpEmbeddingError(e) &&
  e instanceof Error &&
  e.message.startsWith('Embedding endpoint returned empty response');

Try / catch

// Unreachable by design (httpEmbedBatch enforces cardinality in-loop).
try {
  await httpEmbedQuery(text);
} catch (e) {
  if (isDefensiveEmpty(e)) {
    // rule out a live endpoint fault (error 125/127) first; if healthy, report a bug
  }
  throw e;
}

Prevention

When it happens

Trigger: Only if httpEmbedBatch returns [] for a single-text batch without having thrown the in-loop count mismatch — something the current implementation cannot do. Would indicate a regression in httpEmbedBatch or a version skew.

Common situations: Should never occur in normal operation. If seen: a modified httpEmbedBatch that returns [] without validating, or a refactor that removed the in-loop check.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@d540b00184 (2026-08-12). Data as JSON: /api/errors/4ef1527ff9b393c1. Report an issue: GitHub.