Repository navigation
Conversation
The Topic Name of a PUBLISH must not contain `+` or `#`
[MQTT-3.3.2-2]. `publish()` did not check it, so `publish('a/+', ...)`
went to the broker, which may close the connection on it (Aedes
does). With QoS 1/2 the packet stays in the outgoing store and
is sent again after each reconnect, so such a broker closes every new
connection before `connect` is emitted, and the publish callback is
never called.
`publish()` now gives the callback `Invalid topic <topic>` and sends
nothing, like `subscribe()` does for an invalid topic filter.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2124 +/- ##
==========================================
- Coverage 88.81% 88.73% -0.09%
==========================================
Files 26 26
Lines 1905 1909 +4
Branches 453 455 +2
==========================================
+ Hits 1692 1694 +2
- Misses 173 175 +2
Partials 40 40
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ix/publish-wildcard-topic
…topic # Conflicts: # test/node/abstract_client.ts
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.
The Topic Name of a PUBLISH must not contain wildcard characters [MQTT-3.3.2-2].
subscribe()validates its topic filters, butpublish()sent any topic as it was. A broker may close the connection on such a PUBLISH, and with QoS 1/2 the packet stays in the outgoing store and is sent again after every reconnect:publish()now gives the callbackInvalid topic <topic>for a topic with+or#, and sends and stores nothing, likesubscribe()does for an invalid topic filter. Without a callback the publish is dropped, assubscribe()does; happy to emiterrorthere instead if you prefer.Tests
New test in
test/node/abstract_client.ts, so it runs for MQTT 3.1.1, 5, TLS, WebSocket and the unique message id provider:should return an error (via callback) and send nothing for a topic with a wildcardIt fails on
mainand passes with this change. Run locally:client.ts,client_mqtt5.ts,websocket_client.ts,secure_client.ts,unique_message_id_provider_client.ts. Everything passes except tests that also fail onmainon Windows ("should accept the connack of a new connection after a disconnect", and insecure_client.ts"should tear the connection down before emitting a connack timeout"). eslint andtsc --noEmitare clean.This change was written with the help of Claude Code (AI). I reviewed it and ran the tests above.
🤖 Generated with Claude Code