{"record":{"id":"de337f573118f053","repo":"Tencent/WeKnora","slug":"update-wiki-page-meta-w","errorCode":null,"errorMessage":"update wiki page meta: %w","messagePattern":"update wiki page meta: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/wiki_page.go","lineNumber":187,"sourceCode":"\tif contentChanged {\n\t\t// The new version is authored by whoever is driving this write.\n\t\texisting.LastEditSource = types.WikiEditSourceFromContext(ctx)\n\t\texisting.LastEditorID, _ = types.UserIDFromContext(ctx)\n\n\t\t// Snapshot the superseded version and write the new one atomically,\n\t\t// so the content of every past version is preserved and a failed\n\t\t// update leaves no snapshot behind.\n\t\tif err := s.repo.UpdateWithRevision(ctx, existing, revisionFromPage(&prev)); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"update wiki page: %w\", err)\n\t\t}\n\t\t// Bound per-page history; best-effort — a failed prune only means\n\t\t// slightly more storage until the next content change.\n\t\ts.pruneRevisions(ctx, existing.ID, existing.Version)\n\t} else {\n\t\t// No user-visible change — persist bookkeeping fields but preserve\n\t\t// the version so downstream consumers can rely on it.\n\t\tif err := s.repo.UpdateMeta(ctx, existing); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"update wiki page meta: %w\", err)\n\t\t}\n\t}\n\n\t// Update inbound links: remove old, add new. If content didn't change,\n\t// oldOutLinks == existing.OutLinks and these calls are effectively no-ops.\n\ts.removeInLinks(ctx, existing.KnowledgeBaseID, existing.Slug, oldOutLinks)\n\ts.updateInLinks(ctx, existing.KnowledgeBaseID, existing.Slug, existing.OutLinks)\n\n\treturn existing, nil\n}\n\n// UpdatePageMeta updates only metadata (status, source_refs) without version bump or link re-parse.\nfunc (s *wikiPageService) UpdatePageMeta(ctx context.Context, page *types.WikiPage) error {\n\tnormalizeWikiHierarchy(page)\n\tpage.UpdatedAt = time.Now()\n\treturn s.repo.UpdateMeta(ctx, page)\n}\n","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/wiki_page.go#L169-L205","documentation":"UpdatePage wraps the repo failure from UpdateWithRevision, which atomically snapshots the superseded version and writes the new page content. The update (and its revision snapshot) is rolled back as a unit, so no partial history is left behind.","triggerScenarios":"Thrown at internal/application/service/wiki_page.go:187 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check DB connectivity and the wiki repo health","Inspect the wrapped repository error (constraint, conflict)","Retry the page update"],"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"}