{"record":{"id":"957630bed14d0939","repo":"abhigyanpatwari/GitNexus","slug":"embedding-model-not-initialized-run-embedding-pip","errorCode":null,"errorMessage":"Embedding model not initialized. Run embedding pipeline first.","messagePattern":"Embedding model not initialized\\. Run embedding pipeline first\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/embeddings/embedding-pipeline.ts","lineNumber":1013,"sourceCode":"      percent: 0,\n      error: errorMessage,\n    });\n\n    throw error;\n  }\n};\n\n/**\n * Perform semantic search using the vector index with chunk deduplication\n */\nexport const semanticSearch = async (\n  executeQuery: (cypher: string) => Promise<any[]>,\n  query: string,\n  k: number = 10,\n  maxDistance: number = getVectorMaxDistance(DEFAULT_VECTOR_MAX_DISTANCE),\n): Promise<SemanticSearchResult[]> => {\n  if (!isEmbedderReady()) {\n    throw new Error('Embedding model not initialized. Run embedding pipeline first.');\n  }\n\n  const queryEmbedding = await embedText(query);\n  const queryVec = embeddingToArray(queryEmbedding);\n  const queryVecStr = `[${queryVec.join(',')}]`;\n\n  let bestChunks = new Map<\n    string,\n    { distance: number; chunkIndex: number; startLine: number; endLine: number }\n  >();\n  // Query/read path: NEVER spawn a network INSTALL on a user query. If the\n  // VECTOR extension was not pre-installed, fall back to exact scan rather than\n  // blocking the query on a download (offline-first; see extension-loader.ts\n  // \"load-only\" — used by all serve/MCP query paths).\n  if (await loadVectorExtension(undefined, { policy: 'load-only' })) {\n    try {\n      bestChunks = await collectBestChunks(k, async (fetchLimit) => {\n        const vectorQuery = `","sourceCodeStart":995,"sourceCodeEnd":1031,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/gitnexus/src/core/embeddings/embedding-pipeline.ts#L995-L1031","documentation":"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.","triggerScenarios":"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`).","commonSituations":"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.","solutions":["Run `gitnexus analyze --embeddings` to populate the vector index and load the embedder.","If using HTTP mode, ensure GITNEXUS_EMBEDDING_URL and GITNEXUS_EMBEDDING_MODEL are set in the shell that runs `serve`/the query.","Use a non-semantic query (symbol/graph-based) instead — those do not require the embedder."],"exampleFix":"# before — query without embeddings\n$ npx gitnexus serve  # then semantic query → throws\n# after\n$ npx gitnexus analyze --embeddings\n$ npx gitnexus serve  # semantic query now works","handlingStrategy":"validation","validationCode":"import { isEmbedderReady } from 'gitnexus/src/core/embeddings/embedder.js';\n// Gate semantic search on embedder readiness.\nif (!isEmbedderReady()) {\n  throw new Error('Run `gitnexus analyze --embeddings` first, or set GITNEXUS_EMBEDDING_URL+MODEL for HTTP mode.');\n}\nconst results = await semanticSearch(executeQuery, query);","typeGuard":"import { isEmbedderReady } from 'gitnexus/src/core/embeddings/embedder.js';\nconst canRunSemanticSearch = (): boolean => isEmbedderReady();","tryCatchPattern":null,"preventionTips":["Run `analyze --embeddings` before issuing semantic queries.","Keep GITNEXUS_EMBEDDING_URL+MODEL set in every shell that runs serve/queries if using HTTP mode.","Fall back to symbol/graph queries when embeddings are unavailable."],"tags":["embeddings","semantic-search","lifecycle","query"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}