Tencent/WeKnora · error
resolve page folder: %w
Error message
resolve page folder: %w
What it means
applyFolderToPage wraps any GetFolderByID error that is NOT ErrWikiFolderNotFound as 'resolve page folder: %w'. Unlike error 646 (a known-missing folder), this signals an unexpected failure while resolving the folder: DB outage, query error, or canceled context.
Source
Thrown at internal/application/service/wiki_page.go:1395
// applyFolderToPage refreshes a page's derived category_path cache from its
// authoritative FolderID. Root ("") clears the path. A folder id that does not
// resolve is treated as a hard error so we never silently misplace a page.
func (s *wikiPageService) applyFolderToPage(ctx context.Context, page *types.WikiPage) error {
if page == nil {
return nil
}
if strings.TrimSpace(page.FolderID) == "" {
page.FolderID = ""
page.CategoryPath = nil
return nil
}
folder, err := s.repo.GetFolderByID(ctx, page.KnowledgeBaseID, page.FolderID)
if err != nil {
if errors.Is(err, repository.ErrWikiFolderNotFound) {
return fmt.Errorf("wiki page references unknown folder %q", page.FolderID)
}
return fmt.Errorf("resolve page folder: %w", err)
}
page.CategoryPath = types.StringArray(wikiFolderSegments(folder.Path))
return nil
}
// GetFolder retrieves a single folder by id.
func (s *wikiPageService) GetFolder(ctx context.Context, kbID string, id string) (*types.WikiFolder, error) {
return s.repo.GetFolderByID(ctx, kbID, id)
}
// ListChildFolders returns the direct children of parentID for a tree view
// scoped to pageTypes. PageCount is recursive (the folder's whole subtree) so
// a parent reflects everything filed beneath it. A folder is shown when its
// subtree holds a page matching pageTypes. Wholly-empty folders (no pages of
// any type underneath) are only listed when multiple types are requested —
// the merged knowledge view — so single-type tabs like summary do not surface
// empty containers.
func (s *wikiPageService) ListChildFolders(View on GitHub (pinned to 988cbb0330)
Solutions
- Read the wrapped cause (%w) in logs to distinguish connectivity, schema, and timeout failures.
- Retry the operation after transient DB/network failures.
- Verify folder table schema and migrations are current.
- Increase context timeout if large/loaded DBs slow the folder lookup.
Defensive patterns
Strategy: retry
Try / catch
_, err := svc.UpdatePage(ctx, page)
if err != nil && strings.Contains(err.Error(), "resolve page folder:") && !errors.Is(err, repository.ErrWikiFolderNotFound) {
if isTransient(err) || errors.Is(err, context.DeadlineExceeded) {
time.Sleep(backoff)
_, err = svc.UpdatePage(ctx, page)
}
} Prevention
- Monitor DB connectivity; alert on repeated wrapped storage errors
- Keep folder-table schema and migrations current
- Set adequate context timeouts for save operations that resolve folders
- Distinguish this from the unknown-folder case via errors.Is before choosing a recovery path
When it happens
Trigger: CreatePage/UpdatePage/MovePage with a FolderID set while the repository lookup fails unexpectedly — connection loss, SQL error, context deadline exceeded during the folder fetch.
Common situations: Database connectivity loss during page saves; migration/schema issues breaking the folder query; request timeouts canceling the context mid-lookup; permission failures at the storage layer.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- create wiki folder: %w
- failed to ensure FAQ knowledge: %w
- list %s pages: %w
- create wiki page issue: %w
- failed to create chunk: %w
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/4e6ffc66e1057178.
Report an issue: GitHub.