{"record":{"id":"6e84e54939ad5057","repo":"t8y2/dbx","slug":"decode-acl-list-w","errorCode":null,"errorMessage":"decode ACL list: %w","messagePattern":"decode ACL list: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/rocketmq/acl.go","lineNumber":54,"sourceCode":"\tdefer cancel()\n\taddress, err := a.brokerAddressForName(stringValue(params, \"brokerName\"))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresponse, err := invokeRemotingWithClient(ctx, address, remoting.NewRequest(remoting.ListAcl, map[string]string{\n\t\t\"subjectFilter\":  strings.TrimPrefix(stringValue(params, \"principal\", \"subject\"), \"User:\"),\n\t\t\"resourceFilter\": stringValue(params, \"resourceName\"),\n\t}))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar wrapper struct {\n\t\tAcls []aclWire `json:\"acls\"`\n\t}\n\tbody := repairRocketMQJSON(response.Body)\n\tif len(body) > 0 && body[0] == '[' {\n\t\tif err := json.Unmarshal(body, &wrapper.Acls); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"decode ACL list: %w\", err)\n\t\t}\n\t} else if err := json.Unmarshal(body, &wrapper); err != nil {\n\t\treturn nil, fmt.Errorf(\"decode ACL list: %w\", err)\n\t}\n\tprincipalFilter := strings.TrimPrefix(stringValue(params, \"principal\", \"subject\"), \"User:\")\n\tresourceFilter := stringValue(params, \"resourceName\")\n\trows := make([]map[string]any, 0)\n\tfor _, acl := range wrapper.Acls {\n\t\tif principalFilter != \"\" && acl.Subject != principalFilter && acl.Subject != \"User:\"+principalFilter {\n\t\t\tcontinue\n\t\t}\n\t\tfor _, policy := range acl.Policies {\n\t\t\tfor _, entry := range policy.Entries {\n\t\t\t\tif resourceFilter != \"\" && entry.Resource != resourceFilter {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tactions := entry.Actions\n\t\t\t\tif len(actions) == 0 {","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/rocketmq/acl.go#L36-L72","documentation":"listACLs in the RocketMQ driver decodes the admin HTTP response into either a plain array of ACLs or a wrapper object {\"acls\": [...]}. When the body starts with '[' but is not a valid JSON array of ACLs, json.Unmarshal fails and the error is wrapped as 'decode ACL list: <cause>'.","triggerScenarios":"The RocketMQ admin endpoint returned a bracket-leading body that fails to unmarshal into []aclWire — e.g. truncated JSON, a '[object Object]'-style error string, or fields with incompatible types.","commonSituations":"RocketMQ proxy/version returning a different wire format, an auth/error page slipping through with bracket-leading text, network truncation of the response body, schema drift between aclWire and the server's ACL JSON.","solutions":["Log/curl the raw response body from the ACL list endpoint to see what is actually returned","Run the body through repairRocketMQJSON-aware handling and confirm it is valid JSON (validate with jq)","Upgrade or align the RocketMQ server version so its ACL JSON matches aclWire field types","Inspect the wrapped cause (%w) for the exact JSON error, e.g. a type mismatch identifying the offending field"],"exampleFix":"// before\nbody, _ := io.ReadAll(resp.Body) // may be truncated/error page\nacl, err := listACLs(body)\n// after\nif !json.Valid(body) {\n    return fmt.Errorf(\"ACL endpoint returned invalid JSON: %q\", string(body))\n}\nif err := json.Unmarshal(body, &acls); err != nil {\n    return fmt.Errorf(\"decode ACL list: %w (body head: %.200s)\", err, string(body))\n}","handlingStrategy":"try-catch","validationCode":"if !json.Valid(body) {\n    return fmt.Errorf(\"ACL list response is not valid JSON\")\n}\nif len(body) > 0 && body[0] == '[' {\n    var probe []map[string]any\n    if json.Unmarshal(body, &probe) != nil {\n        return fmt.Errorf(\"ACL array decode failed; inspect body: %.200s\", string(body))\n    }\n}","typeGuard":null,"tryCatchPattern":"acls, err := listACLs(params)\nif err != nil {\n    var decErr *json.UnmarshalTypeError\n    if errors.As(err, &decErr) {\n        log.Printf(\"ACL schema drift at %v: %v\", decErr.Field, decErr)\n    }\n    return err\n}","preventionTips":["Log the raw response body when ACL decoding fails (the %w cause pinpoints the field)","Validate the endpoint with jq before wiring it into automation","Pin RocketMQ server version and re-test ACL payloads on upgrades"],"tags":["rocketmq","json","decoding","acl"],"backgroundTag":"json-decode-failed","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}