abhigyanpatwari/GitNexus · error · Error

getEmbedder() is not available in HTTP embedding mode. Use e

Error message

getEmbedder() is not available in HTTP embedding mode. Use embedText()/embedBatch() instead.

What it means

Thrown by getEmbedder() when isHttpMode() is true. getEmbedder() returns the local transformers.js pipeline singleton, which is never loaded in HTTP mode; embedText()/embedBatch() dispatch to httpEmbed() instead. The guard prevents callers from reaching the !embedderInstance branch (error 109) with a confusing message when the real issue is that they are in HTTP mode and should not be calling getEmbedder() at all.

Source

Thrown at gitnexus/src/core/embeddings/embedder.ts:289

};

/**
 * Get the effective embedding dimensions.
 * In HTTP mode, uses GITNEXUS_EMBEDDING_DIMS if set, otherwise the default.
 */
export const getEmbeddingDimensions = (): number => {
  if (isHttpMode()) {
    return getHttpDimensions() ?? DEFAULT_EMBEDDING_CONFIG.dimensions;
  }
  return DEFAULT_EMBEDDING_CONFIG.dimensions;
};

/**
 * Get the embedder instance (throws if not initialized)
 */
export const getEmbedder = (): FeatureExtractionPipeline => {
  if (isHttpMode()) {
    throw new Error(
      'getEmbedder() is not available in HTTP embedding mode. Use embedText()/embedBatch() instead.',
    );
  }
  if (!embedderInstance) {
    throw new Error('Embedder not initialized. Call initEmbedder() first.');
  }
  return embedderInstance;
};

/**
 * Embed a single text string
 *
 * @param text - Text to embed
 * @returns Float32Array of embedding vector
 */
export const embedText = async (
  text: string,
  options: EmbeddingRequestOptions = {},

View on GitHub (pinned to d540b00184)

Solutions

  1. Replace getEmbedder() with embedText()/embedBatch() — they work in both HTTP and local modes.
  2. Gate direct pipeline access on !isHttpMode() and provide an HTTP-mode branch.
  3. If you truly need the pipeline object, you are in local mode — unset the HTTP env vars.

Example fix

// before
const pipe = getEmbedder();
const out = await pipe(text, { pooling: 'mean', normalize: true });
// after
const vec = await embedText(text);
Defensive patterns

Strategy: type-guard

Validate before calling

import { isHttpMode } from 'gitnexus/src/core/embeddings/http-client.js';
// Never call getEmbedder() in HTTP mode.
const pipe = isHttpMode() ? null : getEmbedder();

Type guard

import { isHttpMode } from 'gitnexus/src/core/embeddings/http-client.js';
const canUseLocalPipelineHandle = (): boolean => !isHttpMode();

Prevention

When it happens

Trigger: Custom integration code that calls getEmbedder() directly (rather than embedText/embedBatch) while GITNEXUS_EMBEDDING_URL and GITNEXUS_EMBEDDING_MODEL are both set. The core embedText()/embedBatch() paths check isHttpMode() themselves and never call getEmbedder() in HTTP mode.

Common situations: A fork or plugin that holds a reference to the local pipeline for custom inference; migrating to HTTP mode without updating direct getEmbedder() call sites; an MCP tool that exposes the raw pipeline.

Related errors


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