Skip to content

tedge mqtt sub panics when user provides an invalid MQTT topic #3395

@reubenmiller

Description

@reubenmiller

Describe the bug

tedge mqtt sub panics when provided with an invalid MQTT topic subscription, e.g. # .

$ tedge mqtt sub '# ' --log-level debug

2025-02-12T09:18:59.260233594Z DEBUG tedge_config::tedge_config_cli::tedge_config_location: Loading configuration from "/etc/tedge/tedge.toml"
INFO: Connected
thread 'main' panicked at crates/core/tedge/src/cli/mqtt/subscribe.rs:116:63:
called `Result::unwrap()` on an `Err` value: Request(Subscribe(Filters = [Filter = # , Qos = AtMostOnce], Packet id = 0))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Where as publishing an MQTT message to an invalid topic does not panic, but shows an error.

tedge mqtt pub '# ' ''
Error: failed to publish the message "" on the topic "# " with QoS "AtMostOnce".

Caused by:
    Failed to send mqtt requests to eventloop

To Reproduce

You can reproduced by running:

$ tedge mqtt sub '# ' --log-level debug

Expected behavior

It should not panic, but instead return the error to the user.

Screenshots

Environment (please complete the following information):

Property Value
OS [incl. version] Debian GNU/Linux 12 (bookworm)
Hardware [incl. revision] unknown
System-Architecture Linux tedge 6.8.0-39-generic #39-Ubuntu SMP PREEMPT_DYNAMIC Sat Jul 6 02:50:39 UTC 2024 aarch64 GNU/Linux
thin-edge.io version tedge 1.4.3~135+g9a70777

Additional context

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions