crowdsecurity/crowdsec · error
message for ' ' contains bad data format: missing allowlist…
Error message
message for '%s' contains bad data format: missing allowlist id
What it means
ManagementCmd in the PAPI command handler processes 'allowlist_unsubscribe' messages received from PAPI. Before acting, it validates that the decoded unsubscribe payload carries both a name and an id. This error is returned when message.Header.OperationType indicates an allowlist unsubscribe, but the payload's Id field is empty, so the allowlist cannot be identified for deletion.
Solutions
- Check the sender (PAPI side) so every allowlist_unsubscribe message includes a non-empty 'id' field in its payload.
- Verify the message encoding/decoding path so the Id field is correctly populated (field name/tag mismatch in JSON unmarshal).
- Pin sender and receiver to matching message schema versions to avoid drift where 'id' was renamed or omitted.
Example fix
// before: sending an unsubscribe without id
msg := AllowListUnsubscribeMsg{Name: "my-allowlist"}
// after
if msg.Id == "" { return errors.New("allowlist unsubscribe requires id") }
msg := AllowListUnsubscribeMsg{Name: "my-allowlist", Id: "abc123"} Defensive patterns
Strategy: validation
Validate before calling
if msg.Header.OperationType == "allowlist_unsubscribe" && msg.Payload.Id == "" { return errors.New("cannot send unsubscribe: missing allowlist id") } Try / catch
if err := papi.Send(msg); err != nil { if strings.Contains(err.Error(), "missing allowlist id") { /* repair payload and resend */ } return err } Prevention
- Always populate both Name and Id in allowlist unsubscribe payloads
- Validate outgoing PAPI messages against the schema before publishing
- Add integration tests covering empty-field payloads
When it happens
Trigger: A PAPI-sent allowlist_unsubscribe command message whose parsed unsubscribeMsg.Id is the empty string when ManagementCmd runs (pkg/apiserver/papi_cmd.go:308).
Common situations: Upstream PAPI publishing malformed/incomplete allowlist unsubscribe payloads; schema drift between the PAPI sender and the local decoder leaving Id unset; a manually crafted or replayed message missing the id field.
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 ' ' contains bad data format: missing blocklist…
- message for ' ' contains bad data format: missing allowlist…
- unable to add values to allowlist
- unable to get allowlists
- a condition is required
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/50c5e9d3df846267.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/apiserver/papi_cmd.go:308
}
case "allowlist_unsubscribe":
data, err := json.Marshal(message.Data)
if err != nil {
return err
}
unsubscribeMsg := allowlistUnsubscribe{}
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 allowlist name", message.Header.OperationType)
}
if unsubscribeMsg.Id == "" {
return fmt.Errorf("message for '%s' contains bad data format: missing allowlist id", message.Header.OperationType)
}
p.Logger.Infof("Received allowlist_unsubscribe command from PAPI, unsubscribing from allowlist %s", unsubscribeMsg.Name)
if err := p.DBClient.DeleteAllowListByID(ctx, unsubscribeMsg.Name, unsubscribeMsg.Id, true); err != nil {
if !ent.IsNotFound(err) {
return err
}
p.Logger.Warningf("Allowlist %s not found", unsubscribeMsg.Name)
}
return nil
default:
return fmt.Errorf("unknown command '%s' for operation type '%s'", message.Header.OperationCmd, message.Header.OperationType)
}
return nilView on GitHub (pinned to 909b515798)