Skip to content

preserve v5 properties on retained messages#79

Merged
fabracht merged 4 commits into
mainfrom
fix-retained-message-properties
May 15, 2026
Merged

preserve v5 properties on retained messages#79
fabracht merged 4 commits into
mainfrom
fix-retained-message-properties

Conversation

@fabracht

Copy link
Copy Markdown
Contributor

Fixes #77.

Summary

  • broker::storage::RetainedMessage only stored payload/qos/retain/expiry — response_topic, correlation_data, content_type, user_properties, and payload_format_indicator were dropped on the way into storage and never restored on subscribe.
  • Added those five fields to RetainedMessage, extracted them in RetainedMessage::new and re-attached them in to_publish_packet (same pattern already used by InflightMessage in the same module).
  • All new fields are #[serde(default)] so existing file-backend payloads still deserialize.

Test plan

  • New integration test retained_properties_preserved.rs — late subscriber asserts all five v5 properties survive the retained round-trip. Confirmed to fail before the fix.
  • cargo test -p mqtt5 --lib --bins — 418/418 pass
  • cargo test -p mqtt5 --test integration_complete_flow --test integration_retain_as_published --test message_queuing --test persistence — all pass
  • cargo make ci-verify (pre-commit hook) — fmt + clippy clean on native and wasm

@fabracht fabracht merged commit 52d5677 into main May 15, 2026
15 checks passed
@fabracht fabracht deleted the fix-retained-message-properties branch May 15, 2026 23:40
butterflyfish added a commit to butterflyfish/mqtt-lib that referenced this pull request May 16, 2026
After LabOverWire#79 landed lint cleanup ahead of this PR, the rebase dropped the
overlapping `chore(lint)` commit but reverted two spots where the
reviewer noted my variants were preferable.

- `quic_acceptor.rs`: `#[allow(clippy::collapsible_match, reason = ...)]`
  on the nested match preserves the original control flow rather than
  refactoring to early-`continue`.
- `bench_cmd.rs`: collapse the rate calc to
  `(1_000_000u64 * ...).checked_div(cmd.rate)` returning `Option<u64>`
  directly, replacing the `if cmd.rate > 0 { ... .unwrap_or(0) }` wrap.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] mqtt-lib broker lib does not save retained message properties

1 participant