{"record":{"id":"538a900a89766ebe","repo":"crowdsecurity/crowdsec","slug":"message-for-s-contains-bad-data-format-w","errorCode":null,"errorMessage":"message for '%s' contains bad data format: %w","messagePattern":"message for '(.+?)' contains bad data format: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/apiserver/papi_cmd.go","lineNumber":52,"sourceCode":"\tName string `json:\"name\"`\n\tId   string `json:\"id\"`\n}\n\nfunc DecisionCmd(ctx context.Context, message *Message, p *Papi, sync bool) error {\n\tswitch message.Header.OperationCmd {\n\tcase \"delete\":\n\t\tdata, err := json.Marshal(message.Data)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tUUIDs := make([]string, 0)\n\t\tdeleteDecisionMsg := deleteDecisions{\n\t\t\tDecisions: make([]string, 0),\n\t\t}\n\n\t\tif err := json.Unmarshal(data, &deleteDecisionMsg); 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\tUUIDs = append(UUIDs, deleteDecisionMsg.Decisions...)\n\t\tlog.Infof(\"Decisions UUIDs to remove: %+v\", UUIDs)\n\n\t\tfilter := make(map[string][]string)\n\t\tfilter[\"uuid\"] = UUIDs\n\n\t\t_, deletedDecisions, err := p.DBClient.ExpireDecisionsWithFilter(ctx, filter)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to expire decisions %+v: %w\", UUIDs, err)\n\t\t}\n\n\t\tdecisions := make([]*models.Decision, 0)\n\n\t\tfor _, deletedDecision := range deletedDecisions {\n\t\t\tlog.Infof(\"Decision from '%s' for '%s' (%s) has been deleted\", deletedDecision.Origin, deletedDecision.Value, deletedDecision.Type)\n\t\t\tdec := &models.Decision{","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/apiserver/papi_cmd.go#L34-L70","documentation":"DecisionCmd handles 'delete' decisions messages received from PAPI. The message payload must unmarshal into deleteDecisions (a list of decision UUIDs). This error means the JSON payload for the operation type does not match the expected structure.","triggerScenarios":"json.Unmarshal(data, &deleteDecisionMsg) fails on a delete-decisions PAPI message: wrong field types, malformed JSON, or schema drift between CAPI/PAPI sender and this consumer.","commonSituations":"Incompatible PAPI server version sending a changed payload, a MITM/buggy middlebox altering the message, or custom tooling injecting messages.","solutions":["Verify crowdsec and the PAPI/CAPI source versions match","Dump the raw message data to inspect the actual payload shape","Update crowdsec to the latest version to pick up schema changes","Re-run the pull after confirming server-side health"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"var probe map[string]any; if err := json.Unmarshal(data, &probe); err != nil { return fmt.Errorf(\"payload not JSON\") }; if _, ok := probe[\"decisions\"]; !ok { return fmt.Errorf(\"missing decisions field\") }","typeGuard":null,"tryCatchPattern":"if err := DecisionCmd(ctx, msg, p, false); err != nil { if strings.Contains(err.Error(), \"bad data format\") { log.Errorf(\"unparseable PAPI decision message: %v\", err) } }","preventionTips":["Keep sender and receiver crowdsec versions aligned","Log raw message payloads on failure","Test message schemas after upgrades"],"tags":["json","papi","decisions"],"backgroundTag":"json-unmarshal-failed","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"}