{"record":{"id":"377abb40a6c79c26","repo":"crowdsecurity/crowdsec","slug":"message-for-s-contains-bad-data-format-missing-377abb","errorCode":null,"errorMessage":"message for '%s' contains bad data format: missing allowlist name","messagePattern":"message for '(.+?)' contains bad data format: missing allowlist name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/apiserver/papi_cmd.go","lineNumber":304,"sourceCode":"\t\t\t}\n\t\t\tif deleted > 0 {\n\t\t\t\tlog.Infof(\"deleted %d decisions from allowlists\", deleted)\n\t\t\t}\n\t\t}\n\tcase \"allowlist_unsubscribe\":\n\t\tdata, err := json.Marshal(message.Data)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tunsubscribeMsg := allowlistUnsubscribe{}\n\n\t\tif err := json.Unmarshal(data, &unsubscribeMsg); err != nil {\n\t\t\treturn fmt.Errorf(\"message for '%s' contains bad data format: %w\", message.Header.OperationType, err)\n\t\t}\n\n\t\tif unsubscribeMsg.Name == \"\" {\n\t\t\treturn fmt.Errorf(\"message for '%s' contains bad data format: missing allowlist name\", message.Header.OperationType)\n\t\t}\n\n\t\tif unsubscribeMsg.Id == \"\" {\n\t\t\treturn fmt.Errorf(\"message for '%s' contains bad data format: missing allowlist id\", message.Header.OperationType)\n\t\t}\n\n\t\tp.Logger.Infof(\"Received allowlist_unsubscribe command from PAPI, unsubscribing from allowlist %s\", unsubscribeMsg.Name)\n\n\t\tif err := p.DBClient.DeleteAllowListByID(ctx, unsubscribeMsg.Name, unsubscribeMsg.Id, true); err != nil {\n\t\t\tif !ent.IsNotFound(err) {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tp.Logger.Warningf(\"Allowlist %s not found\", unsubscribeMsg.Name)\n\t\t}\n\n\t\treturn nil\n\tdefault:","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/apiserver/papi_cmd.go#L286-L322","documentation":"After successfully unmarshaling an allowlist_unsubscribe payload, ManagementCmd requires a non-empty Name field to identify the allowlist being unsubscribed. This error is thrown when the payload decodes cleanly but 'name' is empty or absent, meaning the central API sent an incomplete unsubscribe command.","triggerScenarios":"An allowlist_unsubscribe message whose JSON data omits the 'name' key or sets it to \"\" — a placeholder/empty command emitted by the central API or produced by a schema change.","commonSituations":"Central console pushing an unsubscribe for a deleted allowlist with empty metadata; version mismatch between central API and local crowdsec; intermediaries stripping fields from the payload.","solutions":["Check crowdsec logs for the operation_type to identify the malformed command and inspect the corresponding allowlist in the console","Update crowdsec to the latest version so payload handling matches the current central API schema","If persistent, report the malformed message to CrowdSec; the command is rejected and processing continues, so no local action is strictly required","Verify no proxy or custom integration is dropping the 'name' field from PAPI messages"],"exampleFix":"// before: {\"data\":{\"id\":\"42\"}}\n// after: include the name\n// {\"data\":{\"name\":\"my-allowlist\",\"id\":\"42\"}}","handlingStrategy":"validation","validationCode":"msg, ok := message.Data.(map[string]interface{})\nname, ok2 := msg[\"name\"].(string)\nif !ok || !ok2 || name == \"\" {\n    return fmt.Errorf(\"allowlist_unsubscribe payload missing 'name'\")\n}","typeGuard":"func validAllowlistName(d map[string]interface{}) bool {\n    n, ok := d[\"name\"].(string)\n    return ok && n != \"\"\n}","tryCatchPattern":"if err := ManagementCmd(ctx, msg, p, false); err != nil {\n    if strings.Contains(err.Error(), \"missing allowlist name\") {\n        log.Warnf(\"skipping malformed PAPI command: %v\", err)\n        return nil\n    }\n    return err\n}","preventionTips":["Keep the console and crowdsec versions aligned to avoid payload drift","Do not strip fields from PAPI messages in intermediaries","Alert on recurring 'missing allowlist name' log lines as a sender-side defect"],"tags":["crowdsec","papi","websocket","payload-validation"],"backgroundTag":"empty-required-field","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"}