Fix --tail panic on undecryptable events#208
Conversation
listen_tail() assumed every timeline event was a Decrypted variant and called panic!() for anything else. A single unable-to-decrypt (UTD) or plaintext event in the tail window therefore crashed the whole program. Handle the non-Decrypted case gracefully instead: print a notice (in the same style as the messages() RoomEncrypted branch for text output, or the raw JSON for --output json), count it toward err_count, and continue with the next event.
|
@macalinao Since you're already looking at this. Do you think you could add support for plain text events when tailing? I have a use-case where I'd like to use matrix-commander-rs to administer a Tuwunel homeserver on the host via the built-in (unencrypted) admin room. |
|
I do not notice any string typo and the code seems to quickly make sense. I am testing these changes. Improve_websites_thanks_to_open_source/issues/3771 would have helped. |
|
@macalinao Any reason to use Personal notes:Before this pull request: cargo run -- --tailOutput:cargo run -- --tail 1Output:echo $?cargo run -- --tail 1 --room '!sNARMdEsFZERaQAJzl:matrix.org'Output:It seems that I had to start typing on my receiver side for the command to emit and stop. cargo run -- --tail 20 --room '!sNARMdEsFZERaQAJzl:matrix.org'Output:
With this pull request changes: cargo run -- --tail 20Output:Have to check #209 before merging due to: files#diff-624021025ebdbf037d011a86160f2bd2bb2d97cea072753a5dae9526c580cafcR688-R690 DuckDuckGo search https://doc.rust-lang.org/std/option/enum.Option.html#method.unwrap_or_default cargo run -- --tail 16 --output jsonOutput:Unclear why I have Benjamin-Loison/element-android/issues/65 on my Fairphone 4 LineageOS 23.2 and Linux Mint 22.3 Cinnamon Framework 13, especially as this is not this matrix-commander-rs which sent this encrypted message, but it retrieves it correctly for the first one, but not without DuckDuckGo search cargo run -- --tail 16 --output json --log-level debugOutput:DuckDuckGo and Google search AnyTimelineEvent. https://docs.rs/ruma-events/latest/ruma_events/enum.AnyTimelineEvent.html DuckDuckGo search room chunk matrix sdk. https://docs.rs/matrix-sdk/0.18.0/matrix_sdk/room/struct.Room.html https://docs.rs/matrix-sdk/0.18.0/matrix_sdk/room/struct.Messages.html https://docs.rs/matrix-sdk/0.18.0/matrix_sdk/deserialized_responses/struct.TimelineEvent.html cargo run -- --tail 16 --output json --log-level debugOutput:Note: |
|
As my tests look concluding, I merge now and you are free to answer my question thank you for the contribution @macalinao! |
|
Thank you @macalinao. Your PR is appreciated! ❤️ |
|
thank you @Benjamin-Loison for merging 👏 and being so active! |
listen_tail()assumed every fetched timeline event was aDecryptedvariant and called
panic!()for anything else (src/listen.rs:684). Asingle unable-to-decrypt (UTD) or plaintext event in the tail window
therefore crashes the whole program.
This happens routinely on a verified device that is missing the room key for
some older event (e.g. a megolm session that was never in the key backup):
Handle the non-
Decryptedcase gracefully instead: print a notice (in textform, or the raw JSON for
--output json), count it towarderr_count, andcontinue with the next event.
--tailnow prints what it can and skips whatit cannot decrypt.