{"record":{"id":"86ad757f41caf254","repo":"Tencent/WeKnora","slug":"update-auto-linked-content-w","errorCode":null,"errorMessage":"update auto-linked content: %w","messagePattern":"update auto-linked content: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/wiki_page.go","lineNumber":224,"sourceCode":"// UpdateAutoLinkedContent persists content produced by machine-only link\n// decorators (cross-link injection / dead-link cleanup) without bumping\n// `version`. Out-links are re-parsed from the new body and bidirectional\n// in-link references on target pages are refreshed so link navigation stays\n// consistent — only the user-facing revision counter is preserved.\nfunc (s *wikiPageService) UpdateAutoLinkedContent(ctx context.Context, page *types.WikiPage) error {\n\texisting, err := s.repo.GetBySlug(ctx, page.KnowledgeBaseID, page.Slug)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get existing page: %w\", err)\n\t}\n\n\toldOutLinks := existing.OutLinks\n\n\texisting.Content = stripWikiInlineChunkCitations(page.Content)\n\texisting.OutLinks = s.parseOutLinks(existing.Content)\n\texisting.UpdatedAt = time.Now()\n\n\tif err := s.repo.UpdateAutoLinkedContent(ctx, existing); err != nil {\n\t\treturn fmt.Errorf(\"update auto-linked content: %w\", err)\n\t}\n\n\ts.removeInLinks(ctx, existing.KnowledgeBaseID, existing.Slug, oldOutLinks)\n\ts.updateInLinks(ctx, existing.KnowledgeBaseID, existing.Slug, existing.OutLinks)\n\n\treturn nil\n}\n\n// revisionFromPage builds the immutable snapshot row for the given page\n// state. EditSource on the snapshot is the author of THAT version — the\n// page's provenance columns as they stood while the version was current —\n// not whoever is performing the write that supersedes it.\nfunc revisionFromPage(p *types.WikiPage) *types.WikiPageRevision {\n\treturn &types.WikiPageRevision{\n\t\tID:              uuid.New().String(),\n\t\tTenantID:        p.TenantID,\n\t\tKnowledgeBaseID: p.KnowledgeBaseID,\n\t\tPageID:          p.ID,","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/wiki_page.go#L206-L242","documentation":"UpdateAutoLinkedContent wraps the repo update failure after re-parsing out-links. The machine-only write (no version bump) failed, so in-link references on target pages may be stale relative to the intended content.","triggerScenarios":"Thrown at internal/application/service/wiki_page.go:224 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check DB/repo health and the wrapped cause","Retry InjectCrossLinks; the update is idempotent for identical content","Verify the page wasn't concurrently deleted"],"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"}