abhigyanpatwari/GitNexus · error · Error

Embedding model not initialized. Run embedding pipeline firs

Error message

Embedding model not initialized. Run embedding pipeline first.

What it means

Thrown by semanticSearch() when isEmbedderReady() returns false — meaning neither HTTP mode is configured (no GITNEXUS_EMBEDDING_URL+MODEL) nor a local embedder has been initialized. Semantic search must embed the query string before comparing against indexed vectors, so without a ready embedder the query cannot proceed. This guards both the MCP query path and any direct caller of semanticSearch.

Source

Thrown at gitnexus/src/core/embeddings/embedding-pipeline.ts:1013

      percent: 0,
      error: errorMessage,
    });

    throw error;
  }
};

/**
 * Perform semantic search using the vector index with chunk deduplication
 */
export const semanticSearch = async (
  executeQuery: (cypher: string) => Promise<any[]>,
  query: string,
  k: number = 10,
  maxDistance: number = getVectorMaxDistance(DEFAULT_VECTOR_MAX_DISTANCE),
): Promise<SemanticSearchResult[]> => {
  if (!isEmbedderReady()) {
    throw new Error('Embedding model not initialized. Run embedding pipeline first.');
  }

  const queryEmbedding = await embedText(query);
  const queryVec = embeddingToArray(queryEmbedding);
  const queryVecStr = `[${queryVec.join(',')}]`;

  let bestChunks = new Map<
    string,
    { distance: number; chunkIndex: number; startLine: number; endLine: number }
  >();
  // Query/read path: NEVER spawn a network INSTALL on a user query. If the
  // VECTOR extension was not pre-installed, fall back to exact scan rather than
  // blocking the query on a download (offline-first; see extension-loader.ts
  // "load-only" — used by all serve/MCP query paths).
  if (await loadVectorExtension(undefined, { policy: 'load-only' })) {
    try {
      bestChunks = await collectBestChunks(k, async (fetchLimit) => {
        const vectorQuery = `

View on GitHub (pinned to d540b00184)

Solutions

  1. Run `gitnexus analyze --embeddings` to populate the vector index and load the embedder.
  2. If using HTTP mode, ensure GITNEXUS_EMBEDDING_URL and GITNEXUS_EMBEDDING_MODEL are set in the shell that runs `serve`/the query.
  3. Use a non-semantic query (symbol/graph-based) instead — those do not require the embedder.

Example fix

# before — query without embeddings
$ npx gitnexus serve  # then semantic query → throws
# after
$ npx gitnexus analyze --embeddings
$ npx gitnexus serve  # semantic query now works
Defensive patterns

Strategy: validation

Validate before calling

import { isEmbedderReady } from 'gitnexus/src/core/embeddings/embedder.js';
// Gate semantic search on embedder readiness.
if (!isEmbedderReady()) {
  throw new Error('Run `gitnexus analyze --embeddings` first, or set GITNEXUS_EMBEDDING_URL+MODEL for HTTP mode.');
}
const results = await semanticSearch(executeQuery, query);

Type guard

import { isEmbedderReady } from 'gitnexus/src/core/embeddings/embedder.js';
const canRunSemanticSearch = (): boolean => isEmbedderReady();

Prevention

When it happens

Trigger: Calling semanticSearch() (or the MCP `query`/`context` tool's semantic path) before `analyze --embeddings` has been run on the repo, or after a failed init. Also fires when HTTP mode was used at analyze time but the env vars are not set at query time (e.g. different shell for `serve`).

Common situations: Querying a freshly indexed repo that was indexed without --embeddings; running `serve` in a shell without the GITNEXUS_EMBEDDING_URL/MODEL exports that were present during analyze; a previous init failure (error 104/105/106) leaving no embedder.

Related errors


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