{"record":{"id":"b8ed0c0781c6f139","repo":"continuedev/continue","slug":"ollama-generated-empty-embedding","errorCode":null,"errorMessage":"Ollama generated empty embedding","messagePattern":"Ollama generated empty embedding","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"core/llm/llms/Ollama.ts","lineNumber":755,"sourceCode":"    }\n    const resp = await this.fetch(new URL(\"api/embed\", this.apiBase), {\n      method: \"POST\",\n      body: JSON.stringify({\n        model: this.model,\n        input: chunks,\n      }),\n      headers: headers,\n    });\n\n    if (!resp.ok) {\n      throw new Error(`Failed to embed chunk: ${await resp.text()}`);\n    }\n\n    const data = await resp.json();\n    const embedding: number[][] = data.embeddings;\n\n    if (!embedding || embedding.length === 0) {\n      throw new Error(\"Ollama generated empty embedding\");\n    }\n    return embedding;\n  }\n\n  public async installModel(\n    modelName: string,\n    signal: AbortSignal,\n    progressReporter?: (task: string, increment: number, total: number) => void,\n  ): Promise<any> {\n    const modelInfo = await getRemoteModelInfo(modelName, signal);\n    if (!modelInfo) {\n      throw new Error(`'${modelName}' not found in the Ollama registry!`);\n    }\n\n    const release = await Ollama.modelsBeingInstalledMutex.acquire();\n    try {\n      if (Ollama.modelsBeingInstalled.has(modelName)) {\n        throw new Error(`Model '${modelName}' is already being installed.`);","sourceCodeStart":737,"sourceCodeEnd":773,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/core/llm/llms/Ollama.ts#L737-L773","documentation":"Thrown by Ollama._embed when POST /api/embed returned OK but the response contained no usable embeddings array (missing or empty). This indicates a protocol-level anomaly: the server claimed success yet produced no vectors.","triggerScenarios":"Ollama responding 200 with a body lacking 'embeddings' — seen with mismatched Ollama versions, proxies returning an empty 200, or models that return an unexpected response shape.","commonSituations":"Old Ollama builds returning {embedding: [...]} (singular, /api/embeddings format) instead of {embeddings: [...]}, or a middleware stripping the body.","solutions":["Upgrade Ollama to a current version so /api/embed returns the multi-input format","Verify with curl: curl http://localhost:11434/api/embed -d '{\"model\":\"nomic-embed-text\",\"input\":[\"hi\"]}' and check the response contains \"embeddings\"","Remove any proxy between the extension and Ollama"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const r = await fetch(`${host}/api/embed`, { method: 'POST', body: JSON.stringify({ model, input: ['test'] }) });\nconst j = await r.json();\nif (!Array.isArray(j.embeddings) || j.embeddings.length === 0) throw new Error('Ollama /api/embed response malformed — upgrade Ollama');","typeGuard":"interface OllamaEmbedResponse { embeddings?: number[][] }\nconst hasEmbeddings = (j: unknown): j is OllamaEmbedResponse => Array.isArray((j as OllamaEmbedResponse).embeddings) && (j as OllamaEmbedResponse).embeddings!.length > 0;","tryCatchPattern":"try { return await llm.embed(chunks); }\ncatch (e) { if (e instanceof Error && e.message === 'Ollama generated empty embedding') upgradeOllamaHint(); throw e; }","preventionTips":["Require Ollama >= 0.1.27 for embedding workloads","Smoke-test /api/embed once at startup"],"tags":["ollama","embedding","empty-response","version-mismatch"],"backgroundTag":"llm-provider-empty-response","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}