Fenrir fixes#554
Draft
embhorn wants to merge 1 commit into
Draft
Conversation
embhorn
commented
Jun 18, 2026
Member
- Fix f-3626: v5 MqttClient_Publish returns invalid success
There was a problem hiding this comment.
Pull request overview
This PR fixes issue f-3626 by ensuring MQTT v5 broker-side rejections of QoS>0 publishes are surfaced to callers (instead of incorrectly returning success), aligning the client’s publish behavior with how other v5 “ACK-but-rejected” flows are reported.
Changes:
- Add a new return code
MQTT_CODE_ERROR_PUBLISH_REJECTEDfor v5 QoS>0 PUBLISH rejections signaled via PUBACK/PUBREC/PUBCOMP reason codes (>= 0x80). - Update client publish handling to (a) stop QoS2 on PUBREC rejection (no illegal PUBREL) and (b) post-check PUBACK/PUBCOMP reason codes after the wait.
- Add unit tests covering QoS1/QoS2 acceptance vs rejection cases (and a v3.1.1 guard).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| wolfmqtt/mqtt_types.h | Introduces the new MQTT_CODE_ERROR_PUBLISH_REJECTED return code. |
| wolfmqtt/mqtt_client.h | Updates public API docs to mention the new publish rejection code (and adds a note about the write-only path). |
| src/mqtt_client.c | Implements publish rejection detection for v5 PUBACK/PUBREC/PUBCOMP and adds string mapping for the new code. |
| tests/test_mqtt_client.c | Adds regression tests validating correct return codes and QoS2 handshake behavior on v5 rejections. |
| ChangeLog.md | Documents the behavior change and its implications for callers, including MT/write-only caveats. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+347
to
+351
| * \return MQTT_CODE_SUCCESS, | ||
| MQTT_CODE_ERROR_PUBLISH_REJECTED if a v5 broker rejected a | ||
| QoS>0 PUBLISH via a PUBACK (QoS 1) or PUBREC/PUBCOMP (QoS 2) | ||
| reason code >= 0x80 (see MqttPublish.resp.reason_code), or | ||
| MQTT_CODE_ERROR_* (see enum MqttPacketResponseCodes) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.