{"record":{"id":"e485f7d94a5a4496","repo":"Tencent/WeKnora","slug":"cannot-choose-a-knowledge-base-for-new-wiki-page","errorCode":null,"errorMessage":"cannot choose a knowledge base for new wiki page %s: server provenance conflicts across %s","messagePattern":"cannot choose a knowledge base for new wiki page (.+?): server provenance conflicts across (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/tools/wiki_route_resolver.go","lineNumber":199,"sourceCode":"\tallowed := make(map[string]struct{}, len(scopes))\n\tfor _, scope := range scopes {\n\t\tallowed[scope.KnowledgeBaseID] = struct{}{}\n\t}\n\tcandidates := make([]string, 0, len(preferred)+len(serverHints))\n\tfor _, scope := range preferred {\n\t\tcandidates = append(candidates, scope.KnowledgeBaseID)\n\t}\n\tfor _, kbID := range serverHints {\n\t\tif _, ok := allowed[kbID]; ok {\n\t\t\tcandidates = append(candidates, kbID)\n\t\t}\n\t}\n\tcandidates = dedupNonEmptyStrings(candidates)\n\tif len(candidates) == 1 {\n\t\treturn candidates[0], nil\n\t}\n\tif len(candidates) > 1 {\n\t\treturn \"\", fmt.Errorf(\n\t\t\t\"cannot choose a knowledge base for new wiki page %s: server provenance conflicts across %s\",\n\t\t\tslug, strings.Join(candidates, \", \"),\n\t\t)\n\t}\n\tif len(scopes) == 1 {\n\t\treturn scopes[0].KnowledgeBaseID, nil\n\t}\n\treturn \"\", fmt.Errorf(\"cannot choose a knowledge base for new wiki page %s from %d allowed scopes\", slug, len(scopes))\n}\n\nfunc wikiKnowledgeBasesForSourceRefs(\n\tctx context.Context,\n\trefs []string,\n\tknowledgeService interfaces.KnowledgeService,\n\tallowedKBIDs []string,\n) ([]string, error) {\n\tif len(refs) == 0 {\n\t\treturn nil, nil","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/agent/tools/wiki_route_resolver.go#L181-L217","documentation":"resolveWikiCreateKB refuses to pick a creation target when multiple distinct server-side provenance owners (KBs that already contain the slug) conflict. Rather than guessing where to create the new page, it fails with the conflicting candidate KB IDs. This guards against silently creating a duplicate page in the wrong KB.","triggerScenarios":"Creating a wiki page whose slug already resolves (per cached provenance/server hits) to two or more different KBs, so candidates after dedup has length > 1.","commonSituations":"Same slug existing in several KBs when the model issues a create call without specifying a KB; stale provenance cache pointing at multiple owners after page moves; overly broad KB scopes.","solutions":["Explicitly specify the target knowledge base for the create operation instead of relying on inference","Clean up duplicate pages sharing the slug across KBs","Invalidate/repair the provenance cache if it lists KBs that no longer contain the slug","Narrow the allowed scopes before the create call so only one candidate KB remains"],"exampleFix":"// before\nkbID, err := resolveWikiCreateKB(ctx, slug, scopes, routes)\n// after: pin the KB explicitly\nkbID := args[\"knowledge_base_id\"] // require it when ambiguity is possible\nif kbID == \"\" { kbID, err = resolveWikiCreateKB(ctx, slug, scopes, routes) }","handlingStrategy":"validation","validationCode":"owners := provenanceOwnersForSlug(slug, routes) // cached server-side owners\nif len(owners) > 1 {\n    return errors.New(\"ambiguous create target: specify knowledge_base_id explicitly\")\n}\nif kbArg == \"\" { return errors.New(\"knowledge_base_id is required for create\") }","typeGuard":"null","tryCatchPattern":"kbID, err := resolveWikiCreateKB(ctx, slug, scopes, routes)\nif err != nil && strings.Contains(err.Error(), \"provenance conflicts\") {\n    // ask the model/user to pick a KB, then retry with that KB pinned\n}","preventionTips":["Require an explicit knowledge_base_id argument for create operations in multi-KB sessions","Deduplicate slugs across KBs proactively","Invalidate provenance cache entries after page moves/deletes","Audit scopes to avoid accidental multi-KB write sessions"],"tags":["go","wiki","ambiguity","create","provenance"],"backgroundTag":"ambiguous-slug","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}