{"record":{"id":"cb30f92e5370e110","repo":"Tencent/WeKnora","slug":"update-incoming-page-s-w","errorCode":null,"errorMessage":"update incoming page %s: %w","messagePattern":"update incoming page (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/tools/wiki_link_mutation.go","lineNumber":47,"sourceCode":"\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(\n\tctx context.Context,\n\tservice interfaces.WikiPageService,\n\tchanges []appliedWikiContentChange,\n) error {\n\tvar failures []string\n\tfor i := len(changes) - 1; i >= 0; i-- {\n\t\tchange := changes[i]\n\t\tchange.page.Content = change.originalContent\n\t\tif err := service.UpdateAutoLinkedContent(ctx, change.page); err != nil {\n\t\t\tfailures = append(failures, fmt.Sprintf(\"%s: %v\", change.page.Slug, err))","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/agent/tools/wiki_link_mutation.go#L29-L65","documentation":"Persisting a rewritten incoming wiki page failed: UpdateAutoLinkedContent rejected the update after the in-memory content was already mutated, so the page content is restored and the loop stops, returning prior changes for compensation.","triggerScenarios":"Thrown at internal/agent/tools/wiki_link_mutation.go:47 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check page service/storage health from the wrapped error","Resolve optimistic-concurrency conflicts if the page changed concurrently","Invoke rollback of already-applied changes after this failure"],"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"}