embedding-fetch-failure-message.test.mjs
44 lines 1.9 KB
Raw
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf mirror: GitHub Phase A durable MCP OAuth (#270) Human minor ⚠ breaking 12 days 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 4 commits
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf mirror: GitHub Phase A durable MCP OAuth (#270) Human minor 12 days ago
sha256:d8c648b20a4d53b2673c5c082ee7edfa7b2fc9b11080832da1f38807b6bf940b fix(7C-L1b): route hosted delegation proposals through cani… Human minor 32 days ago
sha256:2827ba9e7632a4b141c50caf1e8f7d77abbc3515be20e7465f2bccb0ac4edf91 fix: repair endpoint now sets has_active_subscription when … Human minor 52 days ago