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, err

View on GitHub (pinned to 909b515798)

Solutions

  1. Inspect the wrapped error for the driver-level cause
  2. Restore DB connectivity/permissions (check crowdsec.yaml db_config, file ownership for SQLite)
  3. Verify schema version matches the binary; run migrations/backup-restore as needed
  4. 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

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


AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06). Data as JSON: /api/errors/eed8d76bbe91c4b1. Report an issue: GitHub.