{"record":{"id":"a11456497eb648b4","repo":"chroma-core/chroma","slug":"embedding-function-name-not-found","errorCode":null,"errorMessage":"Embedding function ${name} not found","messagePattern":"Embedding function (.+?) not found","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clients/js/packages/chromadb-core/src/embeddings/registry.ts","lineNumber":19,"sourceCode":"import type { EmbeddingFunctionConstructor } from \"./IEmbeddingFunction\";\nimport * as allEmbeddingFunctions from \"./all\";\n\nconst knownEmbeddingFunctions = new Map<string, EmbeddingFunctionConstructor>(\n  Object.values(allEmbeddingFunctions).map((fn) => [fn.name, fn]),\n);\n\nexport const registerEmbeddingFunction = (fn: EmbeddingFunctionConstructor) => {\n  if (!fn.name) {\n    throw new Error(\"Embedding function must have a name to be registered.\");\n  }\n\n  knownEmbeddingFunctions.set(fn.name, fn);\n};\n\nexport const getEmbeddingFunction = (name: string) => {\n  const fn = knownEmbeddingFunctions.get(name);\n  if (!fn) {\n    throw new Error(`Embedding function ${name} not found`);\n  }\n  return fn;\n};\n","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/clients/js/packages/chromadb-core/src/embeddings/registry.ts#L1-L23","documentation":"getEmbeddingFunction(name) looks up the registry Map that is keyed by each constructor's class name — 'TogetherAIEmbeddingFunction', 'OpenAIEmbeddingFunction', etc. — NOT the instance-level `name` field like 'together_ai'. Any unknown key throws. This is the resolution path used when rehydrating an embedding function from a stored collection config by string.","triggerScenarios":"getEmbeddingFunction('together_ai') — using the instance name instead of the class name; looking up a custom class before registerEmbeddingFunction() ran; typo or case mismatch in the class-name string; bundle A registers a class whose name a minifier changed while bundle B looks up the original name.","commonSituations":"Persisting embedding function names to a database/config and restoring them later; multi-process apps where registration happens in one process and lookup in another; minified builds renaming classes inconsistently.","solutions":["Look up by exported class name exactly as in clients/js/packages/chromadb-core/src/embeddings/all.ts (e.g. 'TogetherAIEmbeddingFunction', 'VoyageAIEmbeddingFunction'), not by instance name like 'together_ai'.","Call registerEmbeddingFunction(YourNamedClass) at process startup, before any code that resolves by name.","Keep class names stable across builds (esbuild --keep-names / terser keep_fnames) if names cross process boundaries.","Wrap lookups in try/catch and surface the failing name in logs to catch typos fast."],"exampleFix":"// before\nconst fn = getEmbeddingFunction(\"together_ai\"); // instance name -> not found\n\n// after\nconst fn = getEmbeddingFunction(\"TogetherAIEmbeddingFunction\"); // registry key is the class name","handlingStrategy":"validation","validationCode":"// Probe before resolving, and fail with the set of valid keys\nconst KNOWN_EMBEDDING_FUNCTIONS = [\n  \"TogetherAIEmbeddingFunction\",\n  \"VoyageAIEmbeddingFunction\",\n  \"TransformersEmbeddingFunction\",\n  /* keep in sync with src/embeddings/all.ts */\n];\nfunction resolveEmbeddingFunction(name: string) {\n  if (!KNOWN_EMBEDDING_FUNCTIONS.includes(name) && !registeredNames.has(name)) {\n    throw new Error(`Unknown embedding function '${name}'. Registered: ${[...registeredNames].join(\", \")}`);\n  }\n  return getEmbeddingFunction(name);\n}","typeGuard":"const isRegisteredEmbeddingName = (name: string): boolean => {\n  try {\n    getEmbeddingFunction(name);\n    return true;\n  } catch {\n    return false;\n  }\n};","tryCatchPattern":"try {\n  const Fn = getEmbeddingFunction(storedName);\n} catch (e) {\n  const msg = e instanceof Error ? e.message : String(e);\n  if (msg.includes(\"not found\")) {\n    // Remember: keys are CLASS names, not instance names like 'together_ai'\n    throw new Error(`Embedding function '${storedName}' is not registered. Register it with registerEmbeddingFunction(YourNamedClass) at startup.`);\n  }\n  throw e;\n}","preventionTips":["Remember the registry is keyed by class name ('TogetherAIEmbeddingFunction'), not the instance name ('together_ai').","Centralize registerEmbeddingFunction calls in a module imported at every process entrypoint.","Persist class names in config and keep them stable across builds (disable class-name mangling)."],"tags":["registry","embeddings","lookup","name-mismatch","deserialization"],"backgroundTag":"embedding-function-not-found","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}