embedding-fetch-failure-message.test.mjs
44 lines 1.9 KB
Raw
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge Human 11 hours ago
1 /**
2 * Semantic search surfaces embedding fetch errors in the Hub; messages must be actionable.
3 */
4 import { describe, it } from 'node:test';
5 import assert from 'node:assert';
6 import { formatEmbeddingFetchFailure } from '../lib/embedding.mjs';
7
8 describe('formatEmbeddingFetchFailure', () => {
9 it('expands Ollama "fetch failed" with host and troubleshooting', () => {
10 const err = new TypeError('fetch failed');
11 err.cause = new Error('connect ECONNREFUSED 127.0.0.1:11434');
12 const s = formatEmbeddingFetchFailure('ollama', 'http://127.0.0.1:11434', 'nomic-embed-text', err);
13 assert.match(s, /Ollama embeddings unreachable/);
14 assert.match(s, /http:\/\/127\.0\.0\.1:11434/);
15 assert.match(s, /ollama serve/);
16 assert.match(s, /ollama pull nomic-embed-text/);
17 assert.match(s, /EMBEDDING_PROVIDER=openai/);
18 assert.match(s, /VOYAGE_API_KEY/);
19 assert.match(s, /ECONNREFUSED|fetch failed/);
20 });
21
22 it('uses default model label when model empty', () => {
23 const err = new TypeError('fetch failed');
24 const s = formatEmbeddingFetchFailure('ollama', 'http://localhost:11434', '', err);
25 assert.match(s, /ollama pull nomic-embed-text/);
26 });
27
28 it('OpenAI path mentions API key and host', () => {
29 const err = new TypeError('fetch failed');
30 err.cause = new Error('getaddrinfo ENOTFOUND api.openai.com');
31 const s = formatEmbeddingFetchFailure('openai', 'https://api.openai.com/v1/embeddings', 'text-embedding-3-small', err);
32 assert.match(s, /OpenAI embeddings request failed/);
33 assert.match(s, /OPENAI_API_KEY/);
34 });
35
36 it('Voyage path mentions API key, provider, and re-index', () => {
37 const err = new TypeError('fetch failed');
38 const s = formatEmbeddingFetchFailure('voyage', 'https://api.voyageai.com/v1/embeddings', 'voyage-4-lite', err);
39 assert.match(s, /Voyage embeddings unreachable/);
40 assert.match(s, /VOYAGE_API_KEY/);
41 assert.match(s, /EMBEDDING_PROVIDER=voyage/);
42 assert.match(s, /re-index/);
43 });
44 });
File History 1 commit
sha256:8915fe406161f95c1681f9469375e7bae5b28c884f00bedbdef65e4b0cd0738d docs(flow): commit FLOW-V0-SPEC.md hygiene for 7A-INT merge Human 11 hours ago