{"record":{"id":"422f5161d92728b9","repo":"Tencent/WeKnora","slug":"failed-to-get-embedding-model-w","errorCode":null,"errorMessage":"failed to get embedding model: %w","messagePattern":"failed to get embedding model: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/knowledge_faq.go","lineNumber":192,"sourceCode":"\t\treturn nil, err\n\t}\n\n\t// 确保FAQ Knowledge存在\n\tfaqKnowledge, err := s.ensureFAQKnowledge(ctx, tenantID, kb)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to ensure FAQ knowledge: %w\", err)\n\t}\n\n\t// 获取索引模式\n\tindexMode := types.FAQIndexModeQuestionOnly\n\tif kb.FAQConfig != nil && kb.FAQConfig.IndexMode != \"\" {\n\t\tindexMode = kb.FAQConfig.IndexMode\n\t}\n\n\t// 获取embedding模型\n\tembeddingModel, err := s.modelService.GetEmbeddingModel(ctx, kb.EmbeddingModelID)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get embedding model: %w\", err)\n\t}\n\n\t// 创建chunk\n\tisEnabled := true\n\tif payload.IsEnabled != nil {\n\t\tisEnabled = *payload.IsEnabled\n\t}\n\t// 默认可推荐\n\tflags := types.ChunkFlagRecommended\n\tif payload.IsRecommended != nil && !*payload.IsRecommended {\n\t\tflags = 0\n\t}\n\n\tchunk := &types.Chunk{\n\t\tID:              uuid.New().String(),\n\t\tTenantID:        tenantID,\n\t\tKnowledgeID:     faqKnowledge.ID,\n\t\tKnowledgeBaseID: kb.ID,","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/knowledge_faq.go#L174-L210","documentation":"CreateFAQEntry wraps failures from modelService.GetEmbeddingModel, which resolves the embedding model configured on the knowledge base (kb.EmbeddingModelID). The FAQ entry cannot be indexed without an embedding model, so creation aborts. The wrapped cause distinguishes 'model not found' from registry/config lookup errors.","triggerScenarios":"Calling CreateFAQEntry on a knowledge base whose EmbeddingModelID points to a deleted, disabled, or nonexistent model, or when the model service itself errors (registry unavailable, tenant mismatch on the model).","commonSituations":"Admin deleted or re-configured the embedding model after the KB was created; environment model registration missing after deployment/migration; wrong tenant context so the model ID doesn't resolve; KB created by import referencing a model that never existed locally.","solutions":["Check kb.EmbeddingModelID and confirm the model exists and is enabled for the tenant in the model service configuration.","Re-assign a valid embedding model to the knowledge base before creating FAQ entries.","If the model registry is a remote service, verify it is reachable and the API key/config is correct.","Audit KBs created by import/migration for dangling EmbeddingModelID values."],"exampleFix":"// before: KB references a removed model\n// kb.EmbeddingModelID = \"emb-old-model\"\n// after: rebind a valid embedding model\nkb, _ := kbRepo.GetByID(ctx, kbID)\nmodels, _ := modelService.ListEmbeddingModels(ctx)\nkb.EmbeddingModelID = models[0].ID\nkbRepo.Update(ctx, kb)","handlingStrategy":"validation","validationCode":"kb, err := svc.GetKnowledgeBase(ctx, kbID)\nif err == nil {\n\tif _, mErr := svc.GetEmbeddingModel(ctx, kb.EmbeddingModelID); mErr != nil {\n\t\treturn fmt.Errorf(\"KB %s has no resolvable embedding model: %w\", kbID, mErr)\n\t}\n}","typeGuard":null,"tryCatchPattern":"entry, err := svc.CreateFAQEntry(ctx, kbID, payload)\nvar nf *NotFoundError\nif errors.As(err, &nf) && strings.Contains(err.Error(), \"embedding model\") {\n\treturn nil, fmt.Errorf(\"rebind an embedding model to KB %s before adding FAQ entries\", kbID)\n}","preventionTips":["Never delete an embedding model still referenced by knowledge bases; reassign KBs first","Validate EmbeddingModelID after KB import/migration","Add a startup/health check that all configured embedding models resolve","Keep model registry config and tenant bindings consistent across environments"],"tags":["embedding","model-config","faq","go"],"backgroundTag":"embedding-model-not-found","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}