Rexit icon indicating copy to clipboard operation
Rexit copied to clipboard

Crash on login to Reddit via token bearer flow

Open dotancohen opened this issue 10 months ago • 6 comments

Bug description

$ export RUST_BACKTRACE=1; rexit messages -t
> Your Bearer Token from Matrix; https://github.com/mpult/rexit/ under Important Notice ********
2025-02-16 12:30 - INFO: Login Successful
2025-02-16 12:30 - INFO: Initializing Image Log
thread 'main' panicked at src/ReAPI/rooms.rs:58:10:
Error parsing array; likely error with login
stack backtrace:
   0: rust_begin_unwind
             at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/core/src/panicking.rs:72:14
   2: core::panicking::panic_display
             at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/core/src/panicking.rs:178:5
   3: core::panicking::panic_str
             at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/core/src/panicking.rs:152:5
   4: core::option::expect_failed
             at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/core/src/option.rs:1985:5
   5: rexit::ReAPI::rooms::download_rooms::{{closure}}
   6: rexit::main::{{closure}}
   7: tokio::runtime::park::CachedParkThread::block_on
   8: tokio::runtime::context::runtime::enter_runtime
   9: tokio::runtime::runtime::Runtime::block_on
  10: rexit::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
  • I'll add the full backtrace to the first comment, to not pollute this bug report.

  • Would you like to work on a fix? [y/n]

No, I do not have the technical capabilities to work on a fix. But if someone wants to mentor me through it, and be patient while I learn Rust along the way, I'm happy to oblige.

To Reproduce

Steps to reproduce the behavior:

  1. Install Rexit via cargo | Build Rexit from the Main branch (I tried both)
  2. Run rexit messages -t
  3. Paste proper, working Authorization header, not including the word "Bearer".
  4. ...
  5. Profit

I am able to reproduce the bug in the main branch, too. That's the backtrace that I'll add to the first comment.

Environment

$ cat /etc/issue
Ubuntu 24.04.1 LTS \n \l

$ ./target/release/rexit -V
rexit 2.0.0

dotancohen avatar Feb 16 '25 12:02 dotancohen

Full backtrace:

$ export RUST_BACKTRACE=full; ./target/release/rexit messages -t
> Your Bearer Token from Matrix; https://github.com/mpult/rexit/ under Important Notice ********
2025-02-16 12:31 - INFO: Login Successful
2025-02-16 12:31 - INFO: Initializing Image Log
thread 'main' panicked at src/ReAPI/rooms.rs:58:10:
Error parsing array; likely error with login
stack backtrace:
   0:     0x5ef669d1f9eb - std::backtrace_rs::backtrace::libunwind::trace::he991e66e5f22a1db
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x5ef669d1f9eb - std::backtrace_rs::backtrace::trace_unsynchronized::h43f35a5576eecb13
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x5ef669d1f9eb - std::sys_common::backtrace::_print_fmt::hf9c799a68b2477fc
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x5ef669d1f9eb - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf2d48dfeb5948660
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x5ef669d612d0 - core::fmt::rt::Argument::fmt::h507ca91fbb1ef494
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/core/src/fmt/rt.rs:142:9
   5:     0x5ef669d612d0 - core::fmt::write::h4d5f6025aa566322
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/core/src/fmt/mod.rs:1120:17
   6:     0x5ef669d12a9d - std::io::Write::write_fmt::hc088b3c8cc6dcb9f
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/io/mod.rs:1762:15
   7:     0x5ef669d1f7d4 - std::sys_common::backtrace::_print::h231201f6cff8f56a
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x5ef669d1f7d4 - std::sys_common::backtrace::print::h478d6be486f8cd2d
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x5ef669d4646a - std::panicking::default_hook::{{closure}}::hf1c55106b4d45a90
  10:     0x5ef669d4610d - std::panicking::default_hook::h7b29000c631cc719
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panicking.rs:292:9
  11:     0x5ef669d46888 - std::panicking::rust_panic_with_hook::h2a988919dd121561
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panicking.rs:779:13
  12:     0x5ef669d1fdce - std::panicking::begin_panic_handler::{{closure}}::h3a9eaa1d23ecf555
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panicking.rs:657:13
  13:     0x5ef669d1fc06 - std::sys_common::backtrace::__rust_end_short_backtrace::h813561fdec15f700
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/sys_common/backtrace.rs:170:18
  14:     0x5ef669d465b2 - rust_begin_unwind
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panicking.rs:645:5
  15:     0x5ef66999da45 - core::panicking::panic_fmt::hef0307862026e6f9
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/core/src/panicking.rs:72:14
  16:     0x5ef66999e163 - core::panicking::panic_display::hed86ea0466f0a3dc
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/core/src/panicking.rs:178:5
  17:     0x5ef66999e163 - core::panicking::panic_str::h1dc008f642ffb82c
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/core/src/panicking.rs:152:5
  18:     0x5ef66999e163 - core::option::expect_failed::hd0fb791ee88ae8a9
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/core/src/option.rs:1985:5
  19:     0x5ef6699aa69b - rexit::ReAPI::rooms::download_rooms::{{closure}}::h585a9246ba9d9f6a
  20:     0x5ef6699afc52 - rexit::main::{{closure}}::h67324918bfa8c1d7
  21:     0x5ef6699a46a9 - tokio::runtime::park::CachedParkThread::block_on::h3de7d07f8020a4b1
  22:     0x5ef6699fa669 - tokio::runtime::context::runtime::enter_runtime::h017ef1660d567986
  23:     0x5ef669a1c7bc - tokio::runtime::runtime::Runtime::block_on::hd63aa9fb2aa1b05b
  24:     0x5ef669a022f8 - rexit::main::h86b0effff57bd36e
  25:     0x5ef669a193b3 - std::sys_common::backtrace::__rust_begin_short_backtrace::h6a22acd0e651be3d
  26:     0x5ef669a23f79 - std::rt::lang_start::{{closure}}::h756c4cba4c452ea4
  27:     0x5ef669d464a4 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h2a98286140a8c485
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/core/src/ops/function.rs:284:13
  28:     0x5ef669d464a4 - std::panicking::try::do_call::h6f884a82d660d639
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panicking.rs:552:40
  29:     0x5ef669d464a4 - std::panicking::try::h3d219ee83761ccf8
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panicking.rs:516:19
  30:     0x5ef669d464a4 - std::panic::catch_unwind::h0a8f78f1f5633cdb
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panic.rs:142:14
  31:     0x5ef669d464a4 - std::rt::lang_start_internal::{{closure}}::hd36869a5192571c4
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/rt.rs:148:48
  32:     0x5ef669d464a4 - std::panicking::try::do_call::hbfe6916f1cc74e35
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panicking.rs:552:40
  33:     0x5ef669d464a4 - std::panicking::try::h0cc643a8ace88736
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panicking.rs:516:19
  34:     0x5ef669d2df4b - std::panic::catch_unwind::hd66d6c526b1a6302
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/panic.rs:142:14
  35:     0x5ef669d2df4b - std::rt::lang_start_internal::h8fc8e9636333b06e
                               at /build/rustc-ntAYxy/rustc-1.75.0+dfsg0ubuntu1/library/std/src/rt.rs:148:20
  36:     0x5ef669a23f6e - std::rt::lang_start::hec1ac5526a26bc1b
  37:     0x72352202a1ca - __libc_start_call_main
                               at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  38:     0x72352202a28b - __libc_start_main_impl
                               at ./csu/../csu/libc-start.c:360:3
  39:     0x5ef66999e3b5 - _start
  40:                0x0 - <unknown>

dotancohen avatar Feb 16 '25 12:02 dotancohen

Hey, long time listener, first time caller. I have zero experience with Rust, and I usually use MacOS. But I was experiencing a similar issue, and I fixed it.

The gottcha for me was this: it turns out, (in powershell at least) if you try to use Ctrl-V to paste into stdin, the only input will be V rather than the clipboard contents. Rexit still says 'Login Successful', but that's not actually an indicator of success.

I used cURL with the bearer token, and to my surprise, got a valid response. So I ended up building it from source and hardcoding the token (even though I figured out later in powershell I could just right click). And everything worked!

I would suggest using cURL or whatever to check the token is valid. Good luck, I hope this helps.

sophie-code-lock avatar Feb 23 '25 18:02 sophie-code-lock

So getting the logs would really help, you can also send me a message to my protonmail on my profile. The token is really long, have you tried waiting 10-15secs after pasting before pressing enter. Its wierd but might work

MPult avatar May 03 '25 09:05 MPult

Same issue here. I checked out v2.0.2 and built from source.

Backtrace:

❯ RUST_BACKTRACE=full ./rexit messages -t
> Your Bearer Token from Matrix; https://github.com/mpult/rexit/ under Important Notice ********
2025-05-08 03:58 - INFO: Login Successful
2025-05-08 03:58 - INFO: Initializing Image Log

thread 'main' panicked at src/ReAPI/rooms.rs:58:10:
Error parsing array; likely error with login
stack backtrace:
   0:        0x104b96b34 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h217270392019d164
   1:        0x104bb516c - core::fmt::write::he22fcab56bd3ec61
   2:        0x104b930a8 - std::io::Write::write_fmt::hb32eaafcfd249a19
   3:        0x104b969e8 - std::sys::backtrace::BacktraceLock::print::h115149c0b879e5c3
   4:        0x104b978cc - std::panicking::default_hook::{{closure}}::h5c3a234feebd11a5
   5:        0x104b97708 - std::panicking::default_hook::ha0b223ccc4379930
   6:        0x104b983fc - std::panicking::rust_panic_with_hook::h203f96c93e7ac62d
   7:        0x104b97fc8 - std::panicking::begin_panic_handler::{{closure}}::hcc8f653f753c0254
   8:        0x104b96fe8 - std::sys::backtrace::__rust_end_short_backtrace::h911de07218b69a6c
   9:        0x104b97c80 - _rust_begin_unwind
  10:        0x104bd0abc - core::panicking::panic_fmt::h6a4014bec58fba4f
  11:        0x104bd0a9c - core::option::expect_failed::h064f2cf84916882a
  12:        0x10488b938 - rexit::ReAPI::rooms::download_rooms::{{closure}}::h9cf20bbdaee1b155
  13:        0x10488f5fc - rexit::main::{{closure}}::h3e8850cef503cfcb
  14:        0x104886874 - tokio::runtime::park::CachedParkThread::block_on::h87bfa0bbe52a96ad
  15:        0x1048e7018 - tokio::runtime::context::runtime::enter_runtime::h64ba1d8e678a6d35
  16:        0x1048cfd3c - tokio::runtime::runtime::Runtime::block_on::h2312610eccfb56a7
  17:        0x1048cb8d4 - rexit::main::h0dcca71bdda527bc
  18:        0x1048e89c4 - std::sys::backtrace::__rust_begin_short_backtrace::h5283c485bc03a75f
  19:        0x1048ee4a4 - std::rt::lang_start::{{closure}}::h0037f0f9071cfcea
  20:        0x104b8c010 - std::rt::lang_start_internal::h95cf27b851151b9c
  21:        0x1048cb9d4 - _main

rexit.log:

2025-05-08 03:54 - TRACE: Bearer token auth flow
2025-05-08 03:54 - TRACE: registering event source with poller: token=Token(0), interests=READABLE
2025-05-08 03:54 - TRACE: registering event source with poller: token=Token(1), interests=READABLE
2025-05-08 03:54 - INFO: Login Successful
2025-05-08 03:54 - INFO: Initializing Image Log
2025-05-08 03:54 - DEBUG: starting new connection: https://matrix.redditspace.com/
2025-05-08 03:54 - DEBUG: downloadRoomsResponse: Object {"errcode": String("M_UNKNOWN_TOKEN"), "error": String("Authorization token is expired or not valid")}
2025-05-08 03:55 - TRACE: Bearer token auth flow
2025-05-08 03:55 - TRACE: registering event source with poller: token=Token(0), interests=READABLE
2025-05-08 03:55 - TRACE: registering event source with poller: token=Token(1), interests=READABLE
2025-05-08 03:55 - INFO: Login Successful
2025-05-08 03:55 - INFO: Initializing Image Log
2025-05-08 03:55 - DEBUG: starting new connection: https://matrix.redditspace.com/
2025-05-08 03:55 - DEBUG: downloadRoomsResponse: Object {"errcode": String("M_UNKNOWN_TOKEN"), "error": String("Authorization token is expired or not valid")}
2025-05-08 03:55 - TRACE: Bearer token auth flow
2025-05-08 03:55 - TRACE: registering event source with poller: token=Token(0), interests=READABLE
2025-05-08 03:55 - TRACE: registering event source with poller: token=Token(1), interests=READABLE
2025-05-08 03:55 - INFO: Login Successful
2025-05-08 03:55 - INFO: Initializing Image Log
2025-05-08 03:55 - DEBUG: starting new connection: https://matrix.redditspace.com/
2025-05-08 03:55 - DEBUG: downloadRoomsResponse: Object {"errcode": String("M_UNKNOWN_TOKEN"), "error": String("Authorization token is expired or not valid")}
2025-05-08 03:56 - TRACE: Bearer token auth flow
2025-05-08 03:56 - TRACE: registering event source with poller: token=Token(0), interests=READABLE
2025-05-08 03:56 - TRACE: registering event source with poller: token=Token(1), interests=READABLE
2025-05-08 03:56 - INFO: Login Successful
2025-05-08 03:56 - INFO: Initializing Image Log
2025-05-08 03:56 - DEBUG: starting new connection: https://matrix.redditspace.com/
2025-05-08 03:56 - DEBUG: downloadRoomsResponse: Object {"errcode": String("M_UNKNOWN_TOKEN"), "error": String("Authorization token is expired or not valid")}
2025-05-08 03:58 - TRACE: Bearer token auth flow
2025-05-08 03:58 - TRACE: registering event source with poller: token=Token(0), interests=READABLE
2025-05-08 03:58 - TRACE: registering event source with poller: token=Token(1), interests=READABLE
2025-05-08 03:58 - INFO: Login Successful
2025-05-08 03:58 - INFO: Initializing Image Log
2025-05-08 03:58 - DEBUG: starting new connection: https://matrix.redditspace.com/
2025-05-08 03:58 - DEBUG: downloadRoomsResponse: Object {"errcode": String("M_UNKNOWN_TOKEN"), "error": String("Authorization token is expired or not valid")}
2025-05-08 03:58 - TRACE: Bearer token auth flow
2025-05-08 03:58 - TRACE: registering event source with poller: token=Token(0), interests=READABLE
2025-05-08 03:58 - TRACE: registering event source with poller: token=Token(1), interests=READABLE
2025-05-08 03:58 - INFO: Login Successful
2025-05-08 03:58 - INFO: Initializing Image Log
2025-05-08 03:58 - DEBUG: starting new connection: https://matrix.redditspace.com/
2025-05-08 03:58 - DEBUG: downloadRoomsResponse: Object {"errcode": String("M_UNKNOWN_TOKEN"), "error": String("Authorization token is expired or not valid")}
2025-05-08 03:58 - TRACE: Bearer token auth flow
2025-05-08 03:58 - TRACE: registering event source with poller: token=Token(0), interests=READABLE
2025-05-08 03:58 - TRACE: registering event source with poller: token=Token(1), interests=READABLE
2025-05-08 03:58 - INFO: Login Successful
2025-05-08 03:58 - INFO: Initializing Image Log
2025-05-08 03:58 - DEBUG: starting new connection: https://matrix.redditspace.com/
2025-05-08 03:58 - DEBUG: downloadRoomsResponse: Object {"errcode": String("M_UNKNOWN_TOKEN"), "error": String("Authorization token is expired or not valid")}

logkirk avatar May 08 '25 04:05 logkirk

Which token are you using to login, as there are two different ones. One for Reddit itself and one for Reddit chat (matrix.redditspace.com)

MPult avatar Jun 04 '25 15:06 MPult

The gottcha for me was this: it turns out, (in powershell at least) if you try to use Ctrl-V to paste into stdin, the only input will be V rather than the clipboard contents. Rexit still says 'Login Successful', but that's not actually an indicator of success.

This was it for me. Use right-click rather than Ctrl+V. Thanks for the tool!

swaree avatar Oct 01 '25 12:10 swaree