crowdsecurity/crowdsec · error
unable to list allowlists: %w
Error message
unable to list allowlists: %w
What it means
ListAllowLists runs an ent query (optionally eager-loading allowlist items) and wraps any query failure as 'unable to list allowlists: %w'. The wrapped error is the ent/driver-level cause, e.g. connection failure or invalid schema.
Source
Thrown at pkg/database/allowlists.go:96
return fmt.Errorf("unable to delete allowlist: %w", err)
}
if nbDeleted == 0 {
return fmt.Errorf("allowlist %s not found", name)
}
return nil
}
func (c *Client) ListAllowLists(ctx context.Context, withContent bool) ([]*ent.AllowList, error) {
q := c.Ent.AllowList.Query()
if withContent {
q = q.WithAllowlistItems()
}
result, err := q.All(ctx)
if err != nil {
return nil, fmt.Errorf("unable to list allowlists: %w", err)
}
return result, nil
}
func (c *Client) GetAllowList(ctx context.Context, name string, withContent bool) (*ent.AllowList, error) {
q := c.Ent.AllowList.Query().Where(allowlist.NameEQ(name))
if withContent {
q = q.WithAllowlistItems()
}
result, err := q.First(ctx)
if err != nil {
if ent.IsNotFound(err) {
return nil, fmt.Errorf("allowlist '%s' not found", name)
}
return nil, errView on GitHub (pinned to 909b515798)
Solutions
- Inspect the wrapped error for the driver-level cause
- Restore DB connectivity/permissions (check crowdsec.yaml db_config, file ownership for SQLite)
- Verify schema version matches the binary; run migrations/backup-restore as needed
- Retry once the database is healthy
Defensive patterns
Strategy: retry
Validate before calling
if err := client.Ent.AllowList.Query().Limit(1).Exec(ctx); err != nil { return fmt.Errorf("db not ready: %w", err) } Try / catch
lists, err := client.ListAllowLists(ctx, withContent)
if err != nil {
if ctx.Err() != nil { return ctx.Err() } // cancelled, not a DB fault
return fmt.Errorf("list allowlists: %w", err)
} Prevention
- Verify db_config in crowdsec.yaml and DB reachability before starting LAPI-dependent services
- Watch disk space and SQLite file permissions
- Use a context with a sane timeout for DB calls
When it happens
Trigger: Client.ListAllowLists (also used by GetAllowlists and GetAllowlistsContentForAPIC) when the DB is down, the allowlists table is missing/corrupted, or the context is cancelled mid-query.
Common situations: LAPI startup against an unavailable or half-migrated database; SQLite file permissions after moving the data dir; disk full; corrupted DB after a crash.
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
- error creating transaction: %w
- unable to remove values from allowlist: %w
- unable to delete allowlist contents: %w
- unable to check if value is allowlisted: %w
- unable to get allowlist items: %w
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/eed8d76bbe91c4b1.
Report an issue: GitHub.