Tencent/WeKnora · error

update wiki page meta: %w

Error message

update wiki page meta: %w

What it means

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.

Source

Thrown at internal/application/service/wiki_page.go:187

	if contentChanged {
		// The new version is authored by whoever is driving this write.
		existing.LastEditSource = types.WikiEditSourceFromContext(ctx)
		existing.LastEditorID, _ = types.UserIDFromContext(ctx)

		// Snapshot the superseded version and write the new one atomically,
		// so the content of every past version is preserved and a failed
		// update leaves no snapshot behind.
		if err := s.repo.UpdateWithRevision(ctx, existing, revisionFromPage(&prev)); err != nil {
			return nil, fmt.Errorf("update wiki page: %w", err)
		}
		// Bound per-page history; best-effort — a failed prune only means
		// slightly more storage until the next content change.
		s.pruneRevisions(ctx, existing.ID, existing.Version)
	} else {
		// No user-visible change — persist bookkeeping fields but preserve
		// the version so downstream consumers can rely on it.
		if err := s.repo.UpdateMeta(ctx, existing); err != nil {
			return nil, fmt.Errorf("update wiki page meta: %w", err)
		}
	}

	// Update inbound links: remove old, add new. If content didn't change,
	// oldOutLinks == existing.OutLinks and these calls are effectively no-ops.
	s.removeInLinks(ctx, existing.KnowledgeBaseID, existing.Slug, oldOutLinks)
	s.updateInLinks(ctx, existing.KnowledgeBaseID, existing.Slug, existing.OutLinks)

	return existing, nil
}

// UpdatePageMeta updates only metadata (status, source_refs) without version bump or link re-parse.
func (s *wikiPageService) UpdatePageMeta(ctx context.Context, page *types.WikiPage) error {
	normalizeWikiHierarchy(page)
	page.UpdatedAt = time.Now()
	return s.repo.UpdateMeta(ctx, page)
}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Check DB connectivity and the wiki repo health
  2. Inspect the wrapped repository error (constraint, conflict)
  3. Retry the page update
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/application/service/wiki_page.go:187 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/de337f573118f053. Report an issue: GitHub.