{"record":{"id":"cb00022c3d2ca799","repo":"t8y2/dbx","slug":"invalid-queue-offset-w","errorCode":null,"errorMessage":"invalid queue offset: %w","messagePattern":"invalid queue offset: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/rocketmq/messages.go","lineNumber":463,"sourceCode":"\tsort.Slice(targets, func(i, j int) bool {\n\t\tif targets[i].BrokerName != targets[j].BrokerName {\n\t\t\treturn targets[i].BrokerName < targets[j].BrokerName\n\t\t}\n\t\treturn targets[i].QueueID < targets[j].QueueID\n\t})\n\treturn targets, nil\n}\n\nfunc queueOffset(ctx context.Context, address, topic string, queueID, requestCode int) (int64, error) {\n\tresponse, err := invokeRemotingWithClient(ctx, address, remoting.NewRequest(requestCode, map[string]string{\n\t\t\"topic\": topic, \"queueId\": strconv.Itoa(queueID),\n\t}))\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\toffset, err := strconv.ParseInt(response.ExtFields[\"offset\"], 10, 64)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"invalid queue offset: %w\", err)\n\t}\n\treturn offset, nil\n}\n\nfunc messageMap(topic string, message *admin.MessageExt) map[string]any {\n\theaders := make(map[string]string, len(message.Properties))\n\tfor key, value := range message.Properties {\n\t\theaders[key] = value\n\t}\n\trow := map[string]any{\n\t\t\"topic\": topic, \"messageId\": message.MsgId, \"partition\": message.QueueId,\n\t\t\"offset\": message.QueueOffset, \"timestamp\": message.StoreTimestamp,\n\t\t\"key\": message.Properties[primitive.PropertyKeys], \"tag\": message.Properties[primitive.PropertyTags],\n\t\t\"headers\": headers, \"payloadBase64\": base64.StdEncoding.EncodeToString(message.Body),\n\t}\n\tif utf8.Valid(message.Body) {\n\t\trow[\"payloadText\"] = string(message.Body)\n\t}","sourceCodeStart":445,"sourceCodeEnd":481,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/rocketmq/messages.go#L445-L481","documentation":"queueOffset issues a max/min-offset remoting request and parses the broker's 'offset' ExtField as int64. If the field is missing or non-numeric, strconv.ParseInt fails and the driver wraps that error with 'invalid queue offset'. It indicates a malformed or unexpected broker response rather than a caller mistake.","triggerScenarios":"Calling peekMessages (which resolves the starting offset via queueOffset) when the broker replies with SUCCESS but no 'offset' ExtField, or a non-numeric value — typically from protocol/version drift or a proxy returning a different response shape.","commonSituations":"Connecting to a RocketMQ 5.x proxy whose responses differ from native broker responses; broker version mismatch putting the offset elsewhere in the response; broker returning an error payload with code 0; intermediary stripping ExtFields.","solutions":["Check broker version and proxy usage; this driver expects native broker remoting responses with 'offset' in ExtFields — target the broker port instead of the proxy.","Log response.ExtFields on failure to see what the broker actually returned.","Align driver and broker versions so the wire protocol matches.","Verify the request code (max/min offset) is supported by the broker version.","Retry once the broker is healthy; degraded brokers can return malformed responses."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"offset, err := peekMessages(params)\nif err != nil {\n    var numErr *strconv.NumError\n    if errors.As(err, &numErr) && strings.Contains(err.Error(), \"invalid queue offset\") {\n        log.Printf(\"broker returned non-numeric offset (check broker/proxy version): %v\", err)\n        return fallbackOffsetQuery(topic, queueID) // use stored checkpoint offset\n    }\n    return err\n}","preventionTips":["Pin driver and broker to compatible RocketMQ versions; avoid mixing proxy (5.x) endpoints with native remoting code paths.","Point the client at the broker listen port, not a proxy, unless the driver explicitly supports proxy mode.","Log response.ExtFields on parse failures to capture what the broker actually sent.","Keep consumer checkpoints so a failed offset lookup can fall back to a known-good offset."],"tags":["rocketmq","protocol","parsing","broker"],"backgroundTag":"invalid-offset-response","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"}