{"record":{"id":"3e98e34f99a36836","repo":"t8y2/dbx","slug":"decode-subscription-groups-w","errorCode":null,"errorMessage":"decode subscription groups: %w","messagePattern":"decode subscription groups: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/rocketmq/consumers.go","lineNumber":618,"sourceCode":"\t\t}\n\t}\n\tif len(merged) == 0 && lastErr != nil {\n\t\treturn nil, lastErr\n\t}\n\treturn merged, nil\n}\n\nfunc fetchSubscriptionGroupConfigs(ctx context.Context, address string) (map[string]*subscriptionGroupConfig, error) {\n\tresponse, err := invokeRemotingWithClient(ctx, address,\n\t\tremoting.NewRequest(remoting.GetAllSubscriptionGroupConfig, nil))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar wrapper struct {\n\t\tSubscriptionGroupTable map[string]*subscriptionGroupConfig `json:\"subscriptionGroupTable\"`\n\t}\n\tif err := json.Unmarshal(repairRocketMQJSON(response.Body), &wrapper); err != nil {\n\t\treturn nil, fmt.Errorf(\"decode subscription groups: %w\", err)\n\t}\n\treturn wrapper.SubscriptionGroupTable, nil\n}\n\nfunc writeSubscriptionGroupConfig(ctx context.Context, address string, config *subscriptionGroupConfig) error {\n\tbody, err := json.Marshal(config)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"encode subscription group config: %w\", err)\n\t}\n\tcommand := remoting.NewRequest(remoting.UpdateAndCreateSubscriptionGroup, nil)\n\tcommand.Body = body\n\t_, err = invokeRemotingWithClient(ctx, address, command)\n\treturn err\n}\n\nfunc ensureMutationCoverage(action, resource string, attempted, succeeded int, lastErr error) error {\n\tif attempted <= 0 {\n\t\treturn fmt.Errorf(\"no RocketMQ master brokers available to %s %s\", action, resource)","sourceCodeStart":600,"sourceCodeEnd":636,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/rocketmq/consumers.go#L600-L636","documentation":"fetchSubscriptionGroupConfigs unmarshals the broker's FETCH_SUBSCRIPTION_GROUP_CONFIG response, expecting {\"subscriptionGroupTable\": {...}}. When json.Unmarshal of the repaired body fails it wraps the cause as \"decode subscription groups\". It means the broker response could not be decoded into the expected wrapper structure.","triggerScenarios":"Calling collectSubscriptionGroupConfigs when a broker returns a non-JSON body (proxy error, empty 200), a different payload shape (older/newer RocketMQ admin API), or fields whose types do not match subscriptionGroupConfig.","commonSituations":"Mixed broker versions in the cluster where some masters return a legacy schema; a gateway on the admin port returning an error page; broker restarted mid-request yielding a truncated body.","solutions":["Dump response.Body to inspect the actual payload and confirm which broker returned it","Check that all master brokers run a RocketMQ version whose FetchSubscriptionGroupConfig response matches the expected subscriptionGroupTable shape","Ensure repairRocketMQJSON normalizes the key casing used by the broker version","Verify network path: query broker admin ports directly, bypassing proxies","Retry the fetch for transient truncation"],"exampleFix":"// before\ntable, err := fetchSubscriptionGroupConfigs(ctx, address)\nif err != nil { return nil, err }\n// after\ntable, err := fetchSubscriptionGroupConfigs(ctx, address)\nif err != nil {\n    return nil, fmt.Errorf(\"fetch subscription groups from %s: %w (broker body may be non-JSON)\", address, err)\n}","handlingStrategy":"try-catch","validationCode":"raw := repairRocketMQJSON(response.Body)\nvar probe map[string]json.RawMessage\nif err := json.Unmarshal(raw, &probe); err != nil || probe[\"subscriptionGroupTable\"] == nil {\n    return fmt.Errorf(\"unexpected subscription group payload: %q\", string(raw))\n}","typeGuard":"func isSubscriptionGroupTablePayload(raw []byte) bool {\n    var probe struct {\n        SubscriptionGroupTable map[string]json.RawMessage `json:\"subscriptionGroupTable\"`\n    }\n    return json.Unmarshal(repairRocketMQJSON(raw), &probe) == nil && probe.SubscriptionGroupTable != nil\n}","tryCatchPattern":"table, err := fetchSubscriptionGroupConfigs(ctx, address)\nif err != nil {\n    log.Printf(\"broker %s returned undecodable subscription groups: %v\", address, err)\n    // fall back to skipping this broker instead of failing the whole collection\n    return nil, err\n}","preventionTips":["Verify broker versions match the driver's expected admin schema","Dump response bodies on failure before debugging schema code","Bypass proxies on broker admin ports","Keep repairRocketMQJSON in sync with broker casing quirks"],"tags":["json","deserialization","rocketmq","subscription-groups"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}