{"record":{"id":"2c6eab8a4e780856","repo":"crowdsecurity/crowdsec","slug":"allowlist-s-not-found-2c6eab","errorCode":null,"errorMessage":"allowlist '%s' not found","messagePattern":"allowlist '(.+?)' not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/database/allowlists.go","lineNumber":111,"sourceCode":"\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\n\t}\n\n\treturn result, nil\n}\n\nfunc (c *Client) GetAllowListByID(ctx context.Context, allowlistID string, withContent bool) (*ent.AllowList, error) {\n\tq := c.Ent.AllowList.Query().Where(allowlist.AllowlistIDEQ(allowlistID))\n\tif withContent {\n\t\tq = q.WithAllowlistItems()\n\t}\n\n\tresult, err := q.First(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/database/allowlists.go#L93-L129","documentation":"GetAllowList queries the allowlists table by exact name (optionally with items) using ent's First(). When ent returns its NotFound error (no row matched), it is converted into a friendly 'allowlist '%s' not found' message. Any other query error is returned unwrapped.","triggerScenarios":"Client.GetAllowList(ctx, name, withContent) — reached from CLI delete/add/remove, import_allowlist, and the API GetAllowlist handler — when no allowlist with exactly that name exists.","commonSituations":"Typo in the allowlist name on cscli allowlists add/remove/import; referencing an allowlist before it was created or after console sync removed it; case/whitespace mismatch since the match is exact (NameEQ).","solutions":["Run cscli allowlists list to get exact names, then retry with the correct name","Create the allowlist first (cscli allowlists create) if it does not exist","If acting by ID (console-managed lists), use GetAllowListByID instead","Check for hidden whitespace/case differences in scripts passing the name"],"exampleFix":"// before\nlist, err := client.GetAllowList(ctx, \"My Allowlist\", true) // exact-match fails\n// after\nlist, err := client.GetAllowList(ctx, strings.TrimSpace(name), true)\nif err != nil { /* create it or abort with a clear message */ }","handlingStrategy":"validation","validationCode":"lists, err := client.ListAllowLists(ctx, false)\nif err != nil { return err }\nexists := false\nfor _, l := range lists { if l.Name == name { exists = true; break } }\nif !exists { return fmt.Errorf(\"allowlist %q not found; available: %v\", name, names) }","typeGuard":null,"tryCatchPattern":"list, err := client.GetAllowList(ctx, name, true)\nif err != nil {\n    if strings.Contains(err.Error(), \"not found\") { return fmt.Errorf(\"unknown allowlist %q\", name) }\n    return err\n}","preventionTips":["Copy allowlist names from cscli allowlists list instead of typing them","Remember the lookup is exact-match on name","For console-managed allowlists, prefer ID-based lookups"],"tags":["database","allowlist","not-found","lookup"],"backgroundTag":"entity-not-found","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"}