Repository navigation
fix: preserve duplicate user properties with empty-string value - #161
Merged
robertsLando merged 1 commit intoJul 14, 2026
Merged
Conversation
The MQTT 5 parser aggregated repeated User Properties sharing a name using a truthiness check on the previously stored value. An empty string is a valid zero-length UTF-8 string but is falsy, so a following occurrence of the same name overwrote it via the else branch instead of appending, silently dropping the empty value and collapsing the array to a scalar. Use an explicit `!== undefined` presence check so every value is retained, per MQTT 5.0 3.3.2.3.7 (a name may appear more than once) and 1.5.4 (UTF-8 strings may be zero length).
robertsLando
approved these changes
Jul 9, 2026
Member
|
@mcollina release? |
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 MQTT 5 parser aggregates repeated User Properties sharing a name using a truthiness check on the previously stored value. An empty string is a valid zero-length UTF-8 string but is falsy, so a following occurrence of the same name takes the first-insert branch and overwrites it instead of appending — silently dropping the empty value and collapsing the array to a scalar.
Repro: parsing a PUBLISH carrying user properties
a=""thena="b"yields{ a: 'b' }instead of{ a: ['', 'b'] }.generateemits both pairs correctly; only the parser loses data, sogenerate → parseis not a round-trip.Use an explicit
!== undefinedpresence check so every value is retained, per MQTT 5.0 §3.3.2.3.7 (a User Property name may appear more than once) and §1.5.4 (UTF-8 encoded strings may be zero length). Adds a regression test.