crowdsecurity/crowdsec · warning
message for '%s' contains bad data format: missing blocklist
Error message
message for '%s' contains bad data format: missing blocklist name
What it means
ManagementCmd processes management commands received over the PAPI websocket from CrowdSec Central API. For a 'blocklist_unsubscribe' command the payload must contain a non-empty 'name' field identifying the blocklist to unsubscribe from. This error is thrown when the JSON payload unmarshals successfully into blocklistUnsubscribe but its Name field is empty, meaning the central API sent a malformed/incomplete message.
Source
Thrown at pkg/apiserver/papi_cmd.go:208
p.Logger.Infof("Ignoring management command from PAPI in sync mode")
return nil
}
switch message.Header.OperationCmd {
case "blocklist_unsubscribe":
data, err := json.Marshal(message.Data)
if err != nil {
return err
}
unsubscribeMsg := blocklistUnsubscribe{}
if err := json.Unmarshal(data, &unsubscribeMsg); err != nil {
return fmt.Errorf("message for '%s' contains bad data format: %w", message.Header.OperationType, err)
}
if unsubscribeMsg.Name == "" {
return fmt.Errorf("message for '%s' contains bad data format: missing blocklist name", message.Header.OperationType)
}
p.Logger.Infof("Received blocklist_unsubscribe command from PAPI, unsubscribing from blocklist %s", unsubscribeMsg.Name)
filter := make(map[string][]string)
filter["origin"] = []string{types.ListOrigin}
filter["scenario"] = []string{unsubscribeMsg.Name}
_, deletedDecisions, err := p.DBClient.ExpireDecisionsWithFilter(ctx, filter)
if err != nil {
return fmt.Errorf("unable to expire decisions for list %s : %w", unsubscribeMsg.Name, err)
}
p.Logger.Infof("deleted %d decisions for list %s", len(deletedDecisions), unsubscribeMsg.Name)
case "reauth":
p.Logger.Infof("Received reauth command from PAPI, resetting token")
p.apiClient.GetClient().Transport.(*apiclient.JWTTransport).ResetToken()
case "force_pull":View on GitHub (pinned to 909b515798)
Solutions
- Check the crowdsec logs for the operation_type in the error to identify which blocklist unsubscribe command was malformed, then inspect the central console for the affected blocklist
- Update crowdsec to the latest version so payload handling matches the current central API schema
- If it persists, report the malformed payload to CrowdSec (the sender side constructs the message); as a workaround the command is simply rejected and processing continues
- Verify no intermediary (proxy, custom integration) rewrites or truncates PAPI websocket messages
Example fix
// before: payload {"operation_cmd":"blocklist_unsubscribe","data":{}}
// after: include the required field
// {"operation_cmd":"blocklist_unsubscribe","data":{"name":"my-blocklist"}} Defensive patterns
Strategy: validation
Validate before calling
msg, ok := message.Data.(map[string]interface{})
name, ok2 := msg["name"].(string)
if !ok || !ok2 || name == "" {
return fmt.Errorf("blocklist_unsubscribe payload missing 'name'")
} Type guard
func validBlocklistUnsubscribe(d map[string]interface{}) bool {
n, ok := d["name"].(string)
return ok && n != ""
} Try / catch
if err := ManagementCmd(ctx, msg, p, false); err != nil {
if strings.Contains(err.Error(), "missing blocklist name") {
log.Warnf("skipping malformed PAPI command: %v", err)
return nil
}
return err
} Prevention
- Keep crowdsec and the enrolled console in sync on versions
- Do not modify or filter PAPI websocket payloads in proxies
- Monitor logs for repeated 'bad data format' messages indicating a sender-side bug
When it happens
Trigger: A blocklist_unsubscribe PAPI message arrives whose JSON data lacks the 'name' key or has it set to "" — e.g. the upstream central API emits an empty placeholder message or a schema change drops the name field.
Common situations: Central API (CAPI) pushing commands with partial payloads; proxy or middleware stripping fields from the websocket message; version mismatch between the console/central API and the local crowdsec agent where the payload shape changed.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- message for '%s' contains bad data format: missing allowlist
- message for '%s' contains bad data format: missing allowlist
- path must start with /
- mtls is selected, but ca_cert is not provided
- invalid auth_type: must be one of basic_auth, headers, mtls
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/8e6b7b5a3c69bd25.
Report an issue: GitHub.