{"record":{"id":"5ff701288217f5f0","repo":"sipeed/picoclaw","slug":"mqtt-publish-failed-w","errorCode":null,"errorMessage":"mqtt: publish failed: %w","messagePattern":"mqtt: publish failed: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/channels/mqtt/mqtt.go","lineNumber":250,"sourceCode":"\t}\n\n\tclientID := strings.TrimPrefix(msg.ChatID, \"mqtt:\")\n\tif clientID == msg.ChatID {\n\t\tlogger.WarnCF(\"mqtt\", \"Send called with unexpected chatID format\", map[string]any{\"chat_id\": msg.ChatID})\n\t\treturn nil, nil\n\t}\n\n\ttopic := fmt.Sprintf(\"%s/%s/%s/response\", c.topicPrefix(), c.cfg.AgentID, clientID)\n\n\tdata, err := json.Marshal(mqttPayload{Text: msg.Content})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"mqtt: failed to marshal outbound payload: %w\", err)\n\t}\n\n\ttoken := c.client.Publish(topic, c.qos, false, data)\n\ttoken.Wait()\n\tif err := token.Error(); err != nil {\n\t\treturn nil, fmt.Errorf(\"mqtt: publish failed: %w\", err)\n\t}\n\n\tlogger.DebugCF(\"mqtt\", \"Published response\", map[string]any{\"topic\": topic})\n\treturn nil, nil\n}\n","sourceCodeStart":232,"sourceCodeEnd":256,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/channels/mqtt/mqtt.go#L232-L256","documentation":"Fired in MQTTChannel.Send when the Publish token for the response topic reports an error after Wait(). Means the broker rejected or failed the outbound publish (connection dropped, QoS issue, or permissions), so the message delivery fails with the wrapped error.","triggerScenarios":"Thrown at pkg/channels/mqtt/mqtt.go:250 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the MQTT connection is alive before publishing (auto-reconnect settings)","Retry the publish; paho reconnects are usually transient","Check broker-side limits such as max packet size or ACLs"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","contentChangedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}