{"record":{"id":"9a74f6d9054ed89d","repo":"crowdsecurity/crowdsec","slug":"unable-to-parse-type","errorCode":null,"errorMessage":"unable to parse type","messagePattern":"unable to parse type","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/database/errors.go","lineNumber":18,"sourceCode":"package database\n\nimport \"errors\"\n\nvar (\n\tUserExists        = errors.New(\"user already exist\")\n\tUserNotExists     = errors.New(\"user doesn't exist\")\n\tHashError         = errors.New(\"unable to hash\")\n\tInsertFail        = errors.New(\"unable to insert row\")\n\tQueryFail         = errors.New(\"unable to query\")\n\tUpdateFail        = errors.New(\"unable to update\")\n\tDeleteFail        = errors.New(\"unable to delete\")\n\tItemNotFound      = errors.New(\"object not found\")\n\tParseTimeFail     = errors.New(\"unable to parse time\")\n\tParseDurationFail = errors.New(\"unable to parse duration\")\n\tMarshalFail       = errors.New(\"unable to serialize\")\n\tBulkError         = errors.New(\"unable to insert bulk\")\n\tParseType         = errors.New(\"unable to parse type\")\n\tInvalidIPOrRange  = errors.New(\"invalid ip address / range\")\n\tInvalidFilter     = errors.New(\"invalid filter\")\n)\n","sourceCodeStart":1,"sourceCodeEnd":22,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/database/errors.go#L1-L22","documentation":"ParseType is a sentinel error meaning a filter value has the wrong type for its key: alertPredicatesFromFilter expected something parseable (e.g. a boolean for 'has_active_decision') but strconv.ParseBool rejected the string. It is the crowdsec filter-language equivalent of a type mismatch.","triggerScenarios":"Querying alerts with filter has_active_decision set to a non-boolean string like \"yes\", \"1a\" or \"true \" (trailing space) via LAPI /v1/alerts.","commonSituations":"Bouncers or scripts building alert queries with human-style booleans (yes/no, on/off), URL-encoded filters with stray whitespace, API consumers guessing value formats instead of using the documented ones.","solutions":["Use strconv.ParseBool-accepted values: 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False.","Trim and URL-encode filter values properly when building the query string.","Check the wrapped inner error for the offending value echoed in the message.","Consult the LAPI filter docs for each key's expected type before querying."],"exampleFix":"// before\nfilter := \"has_active_decision=yes\"\n// after\nfilter := \"has_active_decision=true\"","handlingStrategy":"validation","validationCode":"// Go: validate boolean filter values before querying\nfunc validBoolFilter(s string) bool {\n    _, err := strconv.ParseBool(s)\n    return err == nil\n}","typeGuard":null,"tryCatchPattern":"alerts, err := client.ListAlerts(ctx, filter)\nif err != nil {\n    if errors.Is(err, database.ParseType) {\n        return fmt.Errorf(\"filter value type wrong: %w\", err)\n    }\n    return err\n}","preventionTips":["Use Go strconv.ParseBool-accepted values (true/false/1/0)","Trim and URL-encode filter values","Document expected types for filter keys in API clients"],"tags":["database","crowdsec","filter","parsing"],"backgroundTag":"invalid-argument-format","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}