{"record":{"id":"5394813af528f393","repo":"Tencent/WeKnora","slug":"load-incoming-page-s-w","errorCode":null,"errorMessage":"load incoming page %s: %w","messagePattern":"load incoming page (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/tools/wiki_link_mutation.go","lineNumber":37,"sourceCode":"// applyIncomingWikiContentRewrite updates machine-maintained links without\n// incrementing user-visible page versions. It stops on the first failure and\n// returns the already-applied changes so the caller can compensate.\nfunc applyIncomingWikiContentRewrite(\n\tctx context.Context,\n\tservice interfaces.WikiPageService,\n\tkbID string,\n\tinLinks []string,\n\trewrite wikiContentRewrite,\n) ([]appliedWikiContentChange, []string, error) {\n\tvar changes []appliedWikiContentChange\n\tvar updatedSlugs []string\n\tfor _, sourceSlug := range dedupNonEmptyStrings(inLinks) {\n\t\tpage, err := service.GetPageBySlug(ctx, kbID, sourceSlug)\n\t\tif err != nil || page == nil {\n\t\t\tif err == nil {\n\t\t\t\terr = fmt.Errorf(\"empty result\")\n\t\t\t}\n\t\t\treturn changes, updatedSlugs, fmt.Errorf(\"load incoming page %s: %w\", sourceSlug, err)\n\t\t}\n\t\tupdatedContent, changed := rewrite(page.Content)\n\t\tif !changed {\n\t\t\tcontinue\n\t\t}\n\t\toriginal := page.Content\n\t\tpage.Content = updatedContent\n\t\tif err := service.UpdateAutoLinkedContent(ctx, page); err != nil {\n\t\t\tpage.Content = original\n\t\t\treturn changes, updatedSlugs, fmt.Errorf(\"update incoming page %s: %w\", sourceSlug, err)\n\t\t}\n\t\tchanges = append(changes, appliedWikiContentChange{page: page, originalContent: original})\n\t\tupdatedSlugs = append(updatedSlugs, sourceSlug)\n\t}\n\treturn changes, updatedSlugs, nil\n}\n\nfunc rollbackWikiContentChanges(","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/agent/tools/wiki_link_mutation.go#L19-L55","documentation":"Loading an incoming wiki page by slug failed during the machine-maintained link rewrite: GetPageBySlug errored or returned nothing, so the rewrite loop stops on first failure and returns already-applied changes so the caller can roll back (compensate).","triggerScenarios":"Thrown at internal/agent/tools/wiki_link_mutation.go:37 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Confirm the page slug exists in the knowledge base","Reconcile stale incoming-links metadata","Run the caller's rollback path to undo partial rewrites"],"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-08T10:18:20.063Z"}