Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
test(knowledge): unbreak service test package after tag-loading change
wizardchen6ad75d19fd8f
diff --git a/internal/application/service/knowledge.go b/internal/application/service/knowledge.goindex 838093ebf..7fe4529c0 100644--- a/internal/application/service/knowledge.go+++ b/internal/application/service/knowledge.go@@ -489,7 +489,15 @@ func (s *knowledgeService) GetKnowledgeByIDOnly(ctx context.Context, id string)// KB row itself is not returned so callers can't accidentally widen// their scope past "needed the creator id".func (s *knowledgeService) GetOwningKBCreatorID(ctx context.Context, knowledgeID string) (string, error) {- knowledge, err := s.GetKnowledgeByID(ctx, knowledgeID)+ // Resolve via the repository directly: ownership only needs the+ // knowledge -> kb_id link, so we deliberately skip the service-level+ // GetKnowledgeByID (which also eagerly loads tags) to keep this lookup+ // minimal and tenant-scoped.+ tenantID, ok := ctx.Value(types.TenantIDContextKey).(uint64)+ if !ok {+ return "", werrors.NewUnauthorizedError("Tenant ID not found in context")+ }+ knowledge, err := s.repo.GetKnowledgeByID(ctx, tenantID, knowledgeID)if err != nil {return "", err}diff --git a/internal/application/service/knowledge_create_test.go b/internal/application/service/knowledge_create_test.goindex f5ad1056b..8953f7791 100644--- a/internal/application/service/knowledge_create_test.go+++ b/internal/application/service/knowledge_create_test.go@@ -39,6 +39,15 @@ func (r *createKnowledgeFileRepoStub) CreateKnowledge(ctx context.Context, knowlreturn r.createErr}+// GetKnowledgeTags is invoked by setAndAttachKnowledgeTags after create even+// when no tags were supplied; a fresh knowledge has none, so return empty.+func (r *createKnowledgeFileRepoStub) GetKnowledgeTags(+ ctx context.Context,+ knowledgeIDs []string,+) (map[string][]*types.KnowledgeTag, error) {+ return map[string][]*types.KnowledgeTag{}, nil+}+type createKnowledgeFileKBServiceStub struct {interfaces.KnowledgeBaseService