vxcontrol/pentagi · error
failed to check destination conflicts: %w
Error message
failed to check destination conflicts: %w
What it means
During a directory copy, copyDirResource queries findResourcesByPaths to learn which destination paths already exist. This error wraps a database failure of that lookup (not a conflict — conflicts return errResourceConflict separately). The copy transaction is aborted.
Source
Thrown at backend/pkg/server/services/resources.go:1610
sourceByNewPath := make(map[string]models.UserResource, len(srcEntries))
newPathBySourcePath := make(map[string]string, len(srcEntries))
for _, e := range srcEntries {
newPath := resources.ReplacePrefixPath(e.Path, srcPath, dstPath)
if destExists {
if e.Path == srcPath {
continue
}
rel := strings.TrimPrefix(e.Path, srcPath+"/")
newPath = resources.FilePath(dstPath, rel)
}
newPaths = append(newPaths, newPath)
sourceByNewPath[newPath] = e
newPathBySourcePath[e.Path] = newPath
}
existing, err := findResourcesByPaths(tx, uid, newPaths)
if err != nil {
return result, fmt.Errorf("failed to check destination conflicts: %w", err)
}
if len(existing) > 0 && !force {
return result, errResourceConflict
}
existingSet := make(map[string]models.UserResource, len(existing))
for _, e := range existing {
srcEntry := sourceByNewPath[e.Path]
if e.IsDir != srcEntry.IsDir {
return result, errResourceConflict
}
existingSet[e.Path] = e
}
for _, e := range srcEntries {
if destExists && e.Path == srcPath {
continue
}View on GitHub (pinned to ea665308ba)
Solutions
- Retry the copy request after checking DB health (the wrapped %w cause identifies the actual failure)
- Reduce directory size or batch the copy if the IN-list is too large
- Check Postgres logs and connection pool settings (max open/idle conns)
- Ensure migrations are up to date for the user_resources table
Defensive patterns
Strategy: retry
Try / catch
if err := copyDir(uid, src, dst, force); err != nil {
if strings.Contains(err.Error(), "failed to check destination conflicts") {
// transient DB issue: retry with backoff
return retryWithBackoff(3, func() error { return copyDir(uid, src, dst, force) })
}
return err
} Prevention
- Keep directory trees reasonably sized; archive old subtrees
- Tune DB connection pool and statement timeouts
- Alert on DB health so listing/conflict queries don't fail under load
When it happens
Trigger: findResourcesByPaths fails due to DB connectivity loss, query timeout with very large directory trees (huge newPaths IN-list), or schema/driver errors while calling the copy directory API.
Common situations: Copying a directory with thousands of entries on a slow or flaky database; connection pool exhaustion under load.
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
- failed to copy resource: %w
- failed to copy resource %q: %w
- failed to fetch resources: %w
- failed to delete destination for overwrite: %w
- failed to delete merged source directory %q: %w
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/568b9d690aacf9ae.
Report an issue: GitHub.