{"record":{"id":"979adc9240cfb77f","repo":"Tencent/WeKnora","slug":"failed-to-resolve-wiki-page-s-in-knowledge-base","errorCode":null,"errorMessage":"failed to resolve wiki page %s in knowledge base %s: %w","messagePattern":"failed to resolve wiki page (.+?) in knowledge base (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/tools/wiki_route_resolver.go","lineNumber":139,"sourceCode":"\tslug = strings.TrimSpace(slug)\n\tif slug == \"\" {\n\t\treturn nil, \"\", fmt.Errorf(\"slug is required\")\n\t}\n\tscopes := NewWikiScopesFromKBIDs(kbIDs)\n\tpreferred := routes.scopesForSlug(slug, scopes)\n\tordered := append(append([]WikiScope(nil), preferred...), scopesOutsideKBs(scopes, preferred)...)\n\ttype hit struct {\n\t\tpage *types.WikiPage\n\t\tkbID string\n\t}\n\tvar hits []hit\n\tfor _, scope := range ordered {\n\t\tpage, err := service.GetPageBySlug(ctx, scope.KnowledgeBaseID, slug)\n\t\tif err != nil {\n\t\t\tif errors.Is(err, repository.ErrWikiPageNotFound) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn nil, \"\", fmt.Errorf(\n\t\t\t\t\"failed to resolve wiki page %s in knowledge base %s: %w\",\n\t\t\t\tslug, scope.KnowledgeBaseID, err,\n\t\t\t)\n\t\t}\n\t\tif page == nil {\n\t\t\tcontinue\n\t\t}\n\t\tif page.KnowledgeBaseID != \"\" && page.KnowledgeBaseID != scope.KnowledgeBaseID {\n\t\t\treturn nil, \"\", fmt.Errorf(\n\t\t\t\t\"wiki page %s returned knowledge base %s while resolving allowed scope %s\",\n\t\t\t\tslug, page.KnowledgeBaseID, scope.KnowledgeBaseID,\n\t\t\t)\n\t\t}\n\t\tkbID := scope.KnowledgeBaseID\n\t\thits = append(hits, hit{page: page, kbID: kbID})\n\t\troutes.rememberPage(page, kbID)\n\t}\n\tswitch len(hits) {","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/agent/tools/wiki_route_resolver.go#L121-L157","documentation":"While probing each allowed knowledge-base scope with GetPageBySlug, the resolver ignores ErrWikiPageNotFound but wraps any other lookup failure with this error naming the slug and KB. It preserves the underlying cause via %w so callers can errors.Is/As into it. It signals a real backend failure, not a page-missing case.","triggerScenarios":"service.GetPageBySlug returns a non-ErrWikiPageNotFound error (repository outage, permission error, context cancellation, index/DB failure) for any of the ordered scopes.","commonSituations":"Elasticsearch/DB down or timing out; the KB index deleted or corrupted; authz revoking access mid-request; ctx deadline exceeded while iterating several scopes.","solutions":["Inspect the wrapped cause with errors.Is/As to identify the underlying repository error","Check health/connectivity of the wiki page repository (DB or Elasticsearch) for that KB","Verify service credentials/permissions for the failing knowledge base","Retry with backoff if the cause is transient (timeout/cancellation)"],"exampleFix":"// caller\npage, kbID, err := resolveUniqueWikiPage(ctx, slug, kbIDs, routes)\nif err != nil {\n    if errors.Is(err, repository.ErrWikiPageNotFound) { /* handle miss */ }\n    log.Errorf(\"wiki resolve failed: %v\", err) // prints slug, kb, cause\n}","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"page, kbID, err := resolveUniqueWikiPage(ctx, slug, kbIDs, routes)\nif err != nil {\n    var cause error\n    if errors.As(err, &cause) && !errors.Is(err, errWikiPageNotFoundInScope) {\n        log.Errorf(\"wiki backend failure: %v\", err)\n        // retry with backoff or return 5xx-style tool error\n    }\n}","preventionTips":["Monitor repository/ES health for wiki KB backends","Keep scopes small to reduce per-scope lookup failure surface","Distinguish ErrWikiPageNotFound from other errors in callers","Use ctx with sensible timeout instead of letting deadlines bubble as opaque errors"],"tags":["go","wiki","error-wrapping","repository"],"backgroundTag":"wiki-page-resolution-failed","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}