{"record":{"id":"eed8d76bbe91c4b1","repo":"crowdsecurity/crowdsec","slug":"unable-to-list-allowlists-w","errorCode":null,"errorMessage":"unable to list allowlists: %w","messagePattern":"unable to list allowlists: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/database/allowlists.go","lineNumber":96,"sourceCode":"\t\treturn fmt.Errorf(\"unable to delete allowlist: %w\", err)\n\t}\n\n\tif nbDeleted == 0 {\n\t\treturn fmt.Errorf(\"allowlist %s not found\", name)\n\t}\n\n\treturn nil\n}\n\nfunc (c *Client) ListAllowLists(ctx context.Context, withContent bool) ([]*ent.AllowList, error) {\n\tq := c.Ent.AllowList.Query()\n\tif withContent {\n\t\tq = q.WithAllowlistItems()\n\t}\n\n\tresult, err := q.All(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to list allowlists: %w\", err)\n\t}\n\n\treturn result, nil\n}\n\nfunc (c *Client) GetAllowList(ctx context.Context, name string, withContent bool) (*ent.AllowList, error) {\n\tq := c.Ent.AllowList.Query().Where(allowlist.NameEQ(name))\n\tif withContent {\n\t\tq = q.WithAllowlistItems()\n\t}\n\n\tresult, err := q.First(ctx)\n\tif err != nil {\n\t\tif ent.IsNotFound(err) {\n\t\t\treturn nil, fmt.Errorf(\"allowlist '%s' not found\", name)\n\t\t}\n\n\t\treturn nil, err","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/database/allowlists.go#L78-L114","documentation":"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.","triggerScenarios":"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.","commonSituations":"LAPI startup against an unavailable or half-migrated database; SQLite file permissions after moving the data dir; disk full; corrupted DB after a crash.","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if err := client.Ent.AllowList.Query().Limit(1).Exec(ctx); err != nil { return fmt.Errorf(\"db not ready: %w\", err) }","typeGuard":null,"tryCatchPattern":"lists, err := client.ListAllowLists(ctx, withContent)\nif err != nil {\n    if ctx.Err() != nil { return ctx.Err() } // cancelled, not a DB fault\n    return fmt.Errorf(\"list allowlists: %w\", err)\n}","preventionTips":["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"],"tags":["database","allowlist","query","sql"],"backgroundTag":"database-query-failed","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}