hrkfdn / ncspot

Cross-platform ncurses Spotify client written in Rust, inspired by ncmpc and the likes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Search seems to be broken

xtanion opened this issue · comments

Describe the bug
Searching for a new song crashes the program.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'ncspot'
  2. F2
  3. Search Anything
  4. See Error

Screenshots

2024-02-19.16-13-58.mp4

System (please complete the following information):

  • OS: Debian 12
  • Terminal: GNOME Terminal, Kitty
  • Version: master branch]
  • Installed from: cargo

Backtrace/Debug log

   0: ncspot::panic::register_backtrace_panic_handler::{{closure}}
             at ./src/panic.rs:20:38
   1: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/alloc/src/boxed.rs:2029:9
   2: std::panicking::rust_panic_with_hook
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:783:13
   3: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:649:13
   4: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:171:18
   5: rust_begin_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
   6: core::panicking::panic_fmt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
   7: core::panicking::panic
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:144:5
   8: core::option::Option<T>::unwrap
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/option.rs:931:21
   9: ncspot::ui::search_results::SearchResultsView::run_search
             at ./src/ui/search_results.rs:398:23
  10: ncspot::ui::search_results::SearchResultsView::new
             at ./src/ui/search_results.rs:102:9
  11: ncspot::ui::search::SearchView::new::{{closure}}
             at ./src/ui/search.rs:44:35
  12: <cursive_core::views::edit_view::EditView as cursive_core::view::view_trait::View>::on_event::{{closure}}
             at /home/xtanion/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cursive_core-0.3.7/src/views/edit_view.rs:670:21
  13: cursive_core::event::Callback::from_fn::{{closure}}
             at /home/xtanion/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cursive_core-0.3.7/src/event.rs:189:13
  14: cursive_core::cursive::Cursive::on_event
             at /home/xtanion/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cursive_core-0.3.7/src/cursive.rs:837:17
  15: cursive_core::cursive_run::CursiveRunner<C>::process_events
             at /home/xtanion/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cursive_core-0.3.7/src/cursive_run.rs:125:13
  16: cursive_core::cursive_run::CursiveRunner<C>::step
             at /home/xtanion/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cursive_core-0.3.7/src/cursive_run.rs:216:34
  17: ncspot::application::Application::run
             at ./src/application.rs:225:13
  18: ncspot::main
             at ./src/main.rs:75:13
  19: core::ops::function::FnOnce::call_once
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5
  20: std::sys_common::backtrace::__rust_begin_short_backtrace
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:155:18
  21: std::rt::lang_start::{{closure}}
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/rt.rs:166:18
  22: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:284:13
  23: std::panicking::try::do_call
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
  24: std::panicking::try
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
  25: std::panic::catch_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
  26: std::rt::lang_start_internal::{{closure}}
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/rt.rs:148:48
  27: std::panicking::try::do_call
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
  28: std::panicking::try
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
  29: std::panic::catch_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
  30: std::rt::lang_start_internal
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/rt.rs:148:20
  31: std::rt::lang_start
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/rt.rs:165:17
  32: main
  33: <unknown>
  34: __libc_start_main
  35: _start

panicked at src/ui/search_results.rs:398:55:
called `Option::unwrap()` on a `None` value

Additional context
Add any other context about the problem here.

Looks like this is related to the change from #1396, it probably should not fail on None if the token is still valid:

// token is valid for 5 more minutes, renewal is not necessary yet
if delta.num_seconds() > 60 * 5 {
return None;
}

Could this be it? cc @eprst

Looks like this is related to the change from #1396, it probably should not fail on None if the token is still valid:

// token is valid for 5 more minutes, renewal is not necessary yet
if delta.num_seconds() > 60 * 5 {
return None;
}

Could this be it? cc @eprst

Yes, I think you're correct. Made a PR

@xtanion A fix was merged, could you let us know if it helps?

Works like a charm, thanks for the fix @eprst @hrkfdn 🚀