vxcontrol/pentagi · error
failed to list resources: %w
Error message
failed to list resources: %w
What it means
queryResources runs the listing query (with prefix and recursion filters) via GORM Find and wraps any failure with this message. The wrapped cause is the actual DB error; a returned list simply could not be fetched.
Source
Thrown at backend/pkg/server/services/resources.go:2061
if dirPath != "" {
escaped := resources.EscapeLike(dirPath)
if recursive {
q = q.Where("path = ? OR path LIKE ?", dirPath, escaped+"/%")
} else {
q = q.Where(
"(path = ? AND is_dir = true) OR (path LIKE ? AND path NOT LIKE ?)",
dirPath,
escaped+"/%",
escaped+"/%/%",
)
}
} else if !recursive {
q = q.Where("path NOT LIKE ?", "%/%")
}
var recs []models.UserResource
if err := q.Find(&recs).Error; err != nil {
return nil, fmt.Errorf("failed to list resources: %w", err)
}
return convertResources(recs), nil
}
func (s *ResourceService) resourceExists(uid uint64, vPath string) (bool, error) {
var count int64
err := s.db.Model(&models.UserResource{}).
Where("user_id = ? AND path = ?", uid, vPath).
Count(&count).Error
return count > 0, err
}
func ensureResourceDirs(tx *gorm.DB, uid uint64, dirPath string, force bool) (
[]models.UserResource,
[]models.UserResource,
[]string,
error,
) {View on GitHub (pinned to ea665308ba)
Solutions
- Retry the listing after checking DB health
- Check the wrapped %w cause in server logs for the root driver error
- Verify DB credentials/DSN configuration
- Add pagination/limit if the user has an enormous number of resources
Defensive patterns
Strategy: retry
Try / catch
entries, err := listResources(uid, prefix)
if err != nil {
if isTransientDB(err) { // net timeout, bad connection
return retryWithBackoff(3, func() error { _, err = listResources(uid, prefix); return err })
}
return err
} Prevention
- Monitor DB uptime/credentials; rotate DSN secrets before expiry
- Add pagination for users with very large resource sets
- Set sane statement timeouts and connection pool limits
When it happens
Trigger: GET /resources listing failing because of DB connectivity loss, context timeout on large tables, or a malformed LIKE/prefix filter interacting with schema issues — anything that makes q.Find error.
Common situations: Database under heavy load or restarted mid-request; expired DB credentials; listing very large resource sets timing out.
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 fetch resources: %w
- failed to copy resource: %w
- failed to delete file blocking directory %q: %w
- failed to create resource directory %q: %w
- failed to delete destination for overwrite: %w
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/dcbb057d9af34fdd.
Report an issue: GitHub.