{"record":{"id":"3c37e74fd8717a4a","repo":"crowdsecurity/crowdsec","slug":"s-is-not-a-boolean-w-w","errorCode":null,"errorMessage":"'%s' is not a boolean: %w: %w","messagePattern":"'(.+?)' is not a boolean: %w: %w","errorType":"exception","errorClass":"ParseType","httpStatus":null,"severity":"error","filePath":"pkg/database/alertfilter.go","lineNumber":232,"sourceCode":"\t\t\trng, err = csnet.NewRange(value[0])\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\tcase \"since\", \"created_before\", \"until\":\n\t\t\tif err := handleTimeFilters(param, value[0], &predicates); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\tcase \"decision_type\":\n\t\t\tpredicates = append(predicates, alert.HasDecisionsWith(decision.TypeEQ(value[0])))\n\t\tcase \"origin\":\n\t\t\tpredicates = append(predicates, alert.HasDecisionsWith(decision.OriginEQ(value[0])))\n\t\tcase \"include_capi\": // allows to exclude one or more specific origins\n\t\t\tif err = handleIncludeCapiFilter(value[0], &predicates); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\tcase \"has_active_decision\":\n\t\t\tif hasActiveDecision, err = strconv.ParseBool(value[0]); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"'%s' is not a boolean: %w: %w\", value[0], err, ParseType)\n\t\t\t}\n\n\t\t\tif hasActiveDecision {\n\t\t\t\tpredicates = append(predicates, alert.HasDecisionsWith(decision.UntilGTE(time.Now().UTC())))\n\t\t\t} else {\n\t\t\t\tpredicates = append(predicates, alert.Not(alert.HasDecisions()))\n\t\t\t}\n\t\tcase \"kind\":\n\t\t\tpredicates = append(predicates, alert.KindEQ(value[0]))\n\t\tcase \"limit\":\n\t\t\tcontinue\n\t\tcase \"sort\":\n\t\t\tcontinue\n\t\tcase \"simulated\":\n\t\t\tcontinue\n\t\tcase \"with_decisions\":\n\t\t\tcontinue\n\t\tdefault:","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/database/alertfilter.go#L214-L250","documentation":"The include_capi alert filter parameter was given a value that could not be parsed as a boolean (e.g. \"yes\", \"1x\", empty). The parse error is double-wrapped; the filter string itself is at fault, not the query. This is the generic boolean-parse guard used by handleIncludeCapiFilter.","triggerScenarios":"LAPI request (applyAlertFilter / DeleteAlertWithFilter) with has_active_decision=<non-bool>, e.g. has_active_decision=on or has_active_decision=null.","commonSituations":"Automated scripts sending 'yes'/'no' or empty strings, third-party dashboards using non-Go boolean syntax, copy-pasted URLs with truncated values.","solutions":["Send a Go-parseable boolean: ?has_active_decision=true (or 1/0/t/f).","Fix the integration producing the bad value to serialize booleans as true/false.","Validate before sending (JSON boolean -> string 'true'/'false' conversion).","Check URL encoding — an unencoded '&' or '=' can split the value."],"exampleFix":"// before\nGET /v1/alerts?has_active_decision=on\n// after\nGET /v1/alerts?has_active_decision=true","handlingStrategy":"validation","validationCode":"if b, err := strconv.ParseBool(v); err != nil {\n    return fmt.Errorf(\"has_active_decision must be boolean, got %q\", v)\n} else { _ = b }","typeGuard":null,"tryCatchPattern":"_, err := client.Alerts.List(ctx, models.GetAlertsOpts{HasActiveDecision: &hasActive})\nif err != nil {\n    var apiErr *crowdsec.ApiErrorResponse\n    if errors.As(err, &apiErr) { /* handle 400, correct param */ }\n    return err\n}","preventionTips":["Convert language-native booleans to 'true'/'false' strings before building the query","URL-encode parameters to avoid value splitting","Keep API client libraries updated","Check for typos like 'ture'/'fales' in scripts"],"tags":["go","lapi","query-params"],"backgroundTag":"invalid-query-parameter","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"}