{"record":{"id":"647b0c84c5262684","repo":"Tencent/WeKnora","slug":"failed-to-validate-graph-result-scope-w","errorCode":null,"errorMessage":"failed to validate graph result scope: %w","messagePattern":"failed to validate graph result scope: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/tools/scope_authorization.go","lineNumber":286,"sourceCode":"\t\t\t\t\"graph result document %s belongs to knowledge base %s, expected %s\",\n\t\t\t\tresult.KnowledgeID, result.KnowledgeBaseID, kbID,\n\t\t\t)\n\t\t}\n\t\tif _, ok := explicitSet[result.KnowledgeID]; !ok {\n\t\t\tremainingIDs = append(remainingIDs, result.KnowledgeID)\n\t\t}\n\t}\n\tvar tagMatches map[string]bool\n\tif len(tagIDs) > 0 {\n\t\tif knowledgeService == nil {\n\t\t\treturn nil, fmt.Errorf(\"knowledge service is unavailable for tag-scoped graph filtering\")\n\t\t}\n\t\tvar err error\n\t\ttagMatches, err = knowledgeIDsMatchingAnyTag(\n\t\t\tctx, remainingIDs, tagIDs, knowledgeService.GetKnowledgeTags,\n\t\t)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to validate graph result scope: %w\", err)\n\t\t}\n\t}\n\n\tfiltered := make([]*types.SearchResult, 0, len(results))\n\tfor _, result := range results {\n\t\tif result == nil || result.KnowledgeID == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\t_, explicit := explicitSet[result.KnowledgeID]\n\t\tif explicit || tagMatches[result.KnowledgeID] {\n\t\t\tfiltered = append(filtered, result)\n\t\t}\n\t}\n\treturn filtered, nil\n}\n\nfunc knowledgeIDsMatchingAnyTag(\n\tctx context.Context,","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/agent/tools/scope_authorization.go#L268-L304","documentation":"Tag-based scope resolution for graph results failed: knowledgeIDsMatchingAnyTag errored while checking which candidate documents match the request's tag scope, so the filter cannot certify the remaining results and fails closed.","triggerScenarios":"Thrown at internal/agent/tools/scope_authorization.go:286 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the chained inner error from the tag lookup","Check knowledge/tag service health","Retry transient tag-resolution failures"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}