Repository navigation
Conversation
…tion Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUgePnyPH8ZF4CfNpw
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoUgePnyPH8ZF4CfNpw
…acks' into fix/3216-mqtt-reject-malformed-subscribe
jfallows
changed the base branch from
develop
to
test/3209-mqtt-qos2-interleaved-acks
November 14, 2026 21:09
This was referenced Nov 14, 2026
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.
Description
MqttServerFactoryaccepted several malformed SUBSCRIBE packets. It now answers them as the specifications call for: on MQTT 5, DISCONNECT with the reason code and the connection closes; on MQTT 3.1.1, the connection closes.Changes in
decodeSubscribeV4/decodeSubscribeV5andonDecodeSubscribeV5:decodeUnsubscribeV4/decodeUnsubscribeV5use for UNSUBSCRIBE (payload().sizeof() == 0 || packetId() == 0, Protocol Error 0x82). This is the implementation mirrored.Already handled before this change (no code changed, passing runs below): MQTT 5 Retain Handling 3, MQTT 5 Subscription Identifier 0, MQTT 3.1.1 QoS above 2 and reserved bits.
Fixes #3216
Specification statements
Read in the OASIS pages (MQTT 5.0 and 3.1.1 standard), quoted by sentence:
MQTT 5.0
MQTT 3.1.1
Packet id 0, decision: for 5.0, [MQTT-2.2.1-3] binds only the Client and the text does not say what the Server does on receiving 0. A SUBSCRIBE with id 0 parses, and carries data the protocol does not allow, which is the 1.2 definition of a Protocol Error. 4.13.1 then requires the Server to close the connection and says to send DISCONNECT with 0x82. On 3.1.1, [MQTT-2.3.1-1] binds the packet itself, so [MQTT-4.8.0-1] applies and the connection closes. This is also what the UNSUBSCRIBE decode already does.
Read: the clauses above, in full text. Not read: the remaining sections of both documents (for example 5.0 3.8.4 onwards and 3.1.1 3.8.4 onwards).
Script corrections (scripts that violated the protocol)
v5/subscribe.reject.malformed.subscription.optionsis renamedsubscribe.reject.maximum.qos.3. It expected DISCONNECT 0x81, but 3.8.3.1 says Maximum QoS 3 is a Protocol Error, so it now expects 0x82. It also sent options 0x07 (QoS 3 plus No Local), which would be rejected for the No Local bit alone whennoLocalis off; it now sends 0x03 so the case isolates QoS 3.v5/subscribe.reject.missing.topic.filterscarried the DISCONNECT bytes in the wrong order (properties length before reason code), and the server script labelled the packet SUBACK. Order and label are fixed; the 0x82 reason is unchanged. Neither script ran against the binding before.Test evidence
Commit 1 holds only scripts and ITs (new
.rptpairs and methods in the existingSubscribeITclasses, no new IT classes). Run against the unchanged production code (mvn -B clean verify -pl runtime/binding-mqtt -Dit.test=SubscribeIT), 8 new runtime IT methods failed for the right reason: the script waits for the DISCONNECT, or for the connection close, which never arrives, and times out after 10 s withSpecified behavior did not match expected/TestTimedOutException: test timed out after 10 seconds:shouldRejectMaximumQos3,shouldRejectReservedOptionBit6,shouldRejectReservedOptionBit7,shouldRejectSubscriptionIdRepeated,shouldRejectMissingTopicFilters,shouldRejectPacketIdZeroshouldRejectMissingTopicFilters,shouldRejectPacketIdZeroPassing against the unchanged code, so already handled and not changed: v5
shouldRejectRetainHandling3(theRETAIN_HANDLING_MASKcase incalculateSubscribeFlags), v5shouldReceiveOneMessageWithInvalidSubscriptionId(Subscription Identifier 0), v4shouldRejectMaximumQos3and v4shouldRejectMalformedSubscriptionOptions(options > EXACTLY_ONCE).After the fix (commit 2), cache skipped with
-Dmaven.build.cache.skipCache=true, checkstyle and license checks on:mvn -B -U clean verify -pl runtime/binding-mqtt: 44 unit tests; 430 ITs, 0 failures, 6 skipped. v5SubscribeIT72 and v4SubscribeIT45, all passing.mvn -B -U clean verify -pl specs/binding-mqtt.spec: 78 unit tests (4 skipped); 526 ITs, 0 failures, 2 skipped, including the script-against-script runs of the new pairs.-amfirst. The wrapper could not download its jar (HTTP 429), so the systemmvn3.9.11 was used.Not run: the mqtt-kafka modules. No script they share was changed (only the mqtt modules reference the two changed script names); the other modules and the full reactor were not built. The new scripts were not run against a real MQTT client.
Not delivered
Follow-ups, not part of this change:
onDecodeErrorfromcalculateSubscribeFlagswithout settingdecodeIgnoreAllor leaving the loop, so the subscription is still processed after the DISCONNECT is sent.subscribe.reject.missing.packet.id(v4 and v5) omits the packet id bytes rather than sending id 0, so it does not test this case; it is not run against the binding.Generated by Claude Code