crowdsecurity/crowdsec · error
allowlist %s not found
Error message
allowlist %s not found
What it means
DeleteAllowList deletes an allowlist's items then the allowlist row itself, matched by name and from_console flag. After the delete Exec, if zero rows were removed it means no allowlist with that exact name (and console origin) existed, so the function reports 'allowlist %s not found'. Note the items delete already ran, so this error fires after a successful (empty) delete.
Source
Thrown at pkg/database/allowlists.go:59
func (c *Client) DeleteAllowList(ctx context.Context, name string, fromConsole bool) error {
nbDeleted, err := c.Ent.AllowListItem.Delete().Where(allowlistitem.HasAllowlistWith(allowlist.NameEQ(name), allowlist.FromConsoleEQ(fromConsole))).Exec(ctx)
if err != nil {
return fmt.Errorf("unable to delete allowlist items: %w", err)
}
c.Log.Debugf("deleted %d items from allowlist %s", nbDeleted, name)
nbDeleted, err = c.Ent.AllowList.
Delete().
Where(allowlist.NameEQ(name), allowlist.FromConsoleEQ(fromConsole)).
Exec(ctx)
if err != nil {
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) DeleteAllowListByID(ctx context.Context, name string, allowlistID string, fromConsole bool) error {
nbDeleted, err := c.Ent.AllowListItem.Delete().Where(allowlistitem.HasAllowlistWith(allowlist.AllowlistIDEQ(allowlistID), allowlist.FromConsoleEQ(fromConsole))).Exec(ctx)
if err != nil {
return fmt.Errorf("unable to delete allowlist items: %w", err)
}
c.Log.Debugf("deleted %d items from allowlist %s", nbDeleted, name)
nbDeleted, err = c.Ent.AllowList.
Delete().
Where(allowlist.AllowlistIDEQ(allowlistID), allowlist.FromConsoleEQ(fromConsole)).
Exec(ctx)
if err != nil {View on GitHub (pinned to 909b515798)
Solutions
- List existing allowlists (cscli allowlists list or Client.ListAllowLists) and use the exact name shown
- Match the fromConsole flag: use the console-subcommand variant for console-managed allowlists, the local one for local ones
- If deleting by ID, call DeleteAllowListByID instead of DeleteAllowList
- Treat the error as idempotent: ignore 'not found' if your goal is just to ensure the allowlist is gone
Example fix
// before cscli allowlists delete my-allwlist // after cscli allowlists list # confirm exact name cscli allowlists delete my-allowlist
Defensive patterns
Strategy: validation
Validate before calling
lists, err := client.ListAllowLists(ctx, false)
if err != nil { return err }
found := false
for _, l := range lists {
if l.Name == name && l.FromConsole == fromConsole { found = true; break }
}
if !found { return fmt.Errorf("allowlist %q does not exist; nothing to delete", name) } Try / catch
if err := client.DeleteAllowList(ctx, name, fromConsole); err != nil {
if strings.Contains(err.Error(), "not found") { /* already gone: treat as success */ } else { return err }
} Prevention
- Always fetch the allowlist (GetAllowList) before deleting to confirm name and origin
- Match the fromConsole flag to how the allowlist was created
- Write deletion scripts to be idempotent about 'not found'
When it happens
Trigger: Calling Client.DeleteAllowList(ctx, name, fromConsole) with a name that does not exist in the allowlists table, or an existing allowlist whose FromConsole flag does not match the fromConsole argument (the WHERE clause includes FromConsoleEQ).
Common situations: Typo in 'cscli allowlists delete <name>'; deleting a console-managed allowlist locally without passing the right origin; allowlist already deleted in a prior run or on another node sharing the same database; name vs allowlist_id confusion (delete by name when only an ID is known).
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- allowlist '%s' not found
- object not found
- while getting allowlist %s: %s
- while creating allowlist %s: %s
- while replacing allowlist %s: %s
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/a8f195595d899367.
Report an issue: GitHub.