dominikwilkowski / vault

An open source multi-platform password manager, written in Rust.
https://rustyvault.com/
GNU General Public License v3.0
12 stars 2 forks source link

Creating a new record causes Option::unwrap() on a None value #91

Closed tcullum-rh closed 1 month ago

tcullum-rh commented 1 month ago

Hi,

I entered my vault by submitting the password, clicked to add a new record using the Search bar, selected Username and left as default "Username", selected "Single Secret", and entered "pass" and when I try to save the record, I get the following from Rust:

thread 'main' panicked at src/db.rs:651:66:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: rust_begin_unwind
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:652:5
   1: core::panicking::panic_fmt
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:72:14
   2: core::panicking::panic
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:146:5
   3: core::option::unwrap_failed
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/option.rs:1984:5
   4: core::option::Option<T>::unwrap
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/option.rs:932:21
   5: vault::db::Db::add_field::{{closure}}
             at ./src/db.rs:651:14
   6: <core::slice::iter::IterMut<T> as core::iter::traits::iterator::Iterator>::for_each
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/slice/iter/macros.rs:252:21
   7: vault::db::Db::add_field
             at ./src/db.rs:649:3
   8: vault::ui::details::new_field::save_new_field
             at ./src/ui/details/new_field.rs:72:3
   9: vault::ui::details::new_field::new_field::{{closure}}
             at ./src/ui/details/new_field.rs:282:6
  10: vault::ui::primitives::button::icon_button::{{closure}}
             at ./src/ui/primitives/button.rs:240:4
  11: floem::views::decorator::Decorators::on_click_cont::{{closure}}
             at /home/moveax41h/.cargo/git/checkouts/floem-69eea0a757d1e3ee/3160d2a/src/views/decorator.rs:186:13
  12: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2036:9
  13: floem::context::EventCx::unconditional_view_event::{{closure}}
             at /home/moveax41h/.cargo/git/checkouts/floem-69eea0a757d1e3ee/3160d2a/src/context.rs:371:43
  14: <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::fold
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/slice/iter/macros.rs:230:27
  15: floem::context::EventCx::unconditional_view_event
             at /home/moveax41h/.cargo/git/checkouts/floem-69eea0a757d1e3ee/3160d2a/src/context.rs:370:32
  16: floem::context::EventCx::unconditional_view_event
             at /home/moveax41h/.cargo/git/checkouts/floem-69eea0a757d1e3ee/3160d2a/src/context.rs:165:24
  17: floem::context::EventCx::unconditional_view_event
             at /home/moveax41h/.cargo/git/checkouts/floem-69eea0a757d1e3ee/3160d2a/src/context.rs:165:24
  18: floem::context::EventCx::unconditional_view_event
             at /home/moveax41h/.cargo/git/checkouts/floem-69eea0a757d1e3ee/3160d2a/src/context.rs:165:24
  19: floem::context::EventCx::unconditional_view_event
             at /home/moveax41h/.cargo/git/checkouts/floem-69eea0a757d1e3ee/3160d2a/src/context.rs:165:24
  20: floem::context::EventCx::unconditional_view_event
             at /home/moveax41h/.cargo/git/checkouts/floem-69eea0a757d1e3ee/3160d2a/src/context.rs:165:24
  21: floem::context::EventCx::unconditional_view_event
             at /home/moveax41h/.cargo/git/checkouts/floem-69eea0a757d1e3ee/3160d2a/src/context.rs:165:24
  22: floem::context::EventCx::unconditional_view_event
             at /home/moveax41h/.cargo/git/checkouts/floem-69eea0a757d1e3ee/3160d2a/src/context.rs:165:24
  23: floem::context::EventCx::unconditional_view_event
             at /home/moveax41h/.cargo/git/checkouts/floem-69eea0a757d1e3ee/3160d2a/src/context.rs:165:24
  24: floem::context::EventCx::unconditional_view_event
             at /home/moveax41h/.cargo/git/checkouts/floem-69eea0a757d1e3ee/3160d2a/src/context.rs:165:24
  25: floem::context::EventCx::unconditional_view_event
             at /home/moveax41h/.cargo/git/checkouts/floem-69eea0a757d1e3ee/3160d2a/src/context.rs:165:24
  26: floem::context::EventCx::unconditional_view_event
             at /home/moveax41h/.cargo/git/checkouts/floem-69eea0a757d1e3ee/3160d2a/src/context.rs:165:24
  27: floem::context::EventCx::unconditional_view_event
             at /home/moveax41h/.cargo/git/checkouts/floem-69eea0a757d1e3ee/3160d2a/src/context.rs:165:24
  28: floem::context::EventCx::unconditional_view_event
             at /home/moveax41h/.cargo/git/checkouts/floem-69eea0a757d1e3ee/3160d2a/src/context.rs:165:24
  29: floem::window_handle::WindowHandle::event
             at /home/moveax41h/.cargo/git/checkouts/floem-69eea0a757d1e3ee/3160d2a/src/window_handle.rs:272:13
  30: floem::window_handle::WindowHandle::mouse_input
             at /home/moveax41h/.cargo/git/checkouts/floem-69eea0a757d1e3ee/3160d2a/src/window_handle.rs:479:17
  31: floem::app_handle::ApplicationHandle::handle_window_event
             at /home/moveax41h/.cargo/git/checkouts/floem-69eea0a757d1e3ee/3160d2a/src/app_handle.rs:205:17
  32: floem::app::Application::run::{{closure}}
             at /home/moveax41h/.cargo/git/checkouts/floem-69eea0a757d1e3ee/3160d2a/src/app.rs:151:21
  33: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:294:13
  34: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:294:13
  35: floem_winit::platform_impl::platform::wayland::event_loop::EventLoop<T>::single_iteration
             at /home/moveax41h/.cargo/registry/src/index.crates.io-6f17d22bba15001f/floem-winit-0.29.4/src/platform_impl/linux/wayland/event_loop/mod.rs:461:13
  36: floem_winit::platform_impl::platform::wayland::event_loop::EventLoop<T>::poll_events_with_timeout
             at /home/moveax41h/.cargo/registry/src/index.crates.io-6f17d22bba15001f/floem-winit-0.29.4/src/platform_impl/linux/wayland/event_loop/mod.rs:323:9
  37: floem_winit::platform_impl::platform::wayland::event_loop::EventLoop<T>::pump_events
             at /home/moveax41h/.cargo/registry/src/index.crates.io-6f17d22bba15001f/floem-winit-0.29.4/src/platform_impl/linux/wayland/event_loop/mod.rs:237:13
  38: floem_winit::platform_impl::platform::wayland::event_loop::EventLoop<T>::run_on_demand
             at /home/moveax41h/.cargo/registry/src/index.crates.io-6f17d22bba15001f/floem-winit-0.29.4/src/platform_impl/linux/wayland/event_loop/mod.rs:201:19
  39: floem_winit::platform_impl::platform::EventLoop<T>::run_on_demand
             at /home/moveax41h/.cargo/registry/src/index.crates.io-6f17d22bba15001f/floem-winit-0.29.4/src/platform_impl/linux/mod.rs:821:56
  40: floem_winit::platform_impl::platform::EventLoop<T>::run
             at /home/moveax41h/.cargo/registry/src/index.crates.io-6f17d22bba15001f/floem-winit-0.29.4/src/platform_impl/linux/mod.rs:814:9
  41: floem_winit::event_loop::EventLoop<T>::run
             at /home/moveax41h/.cargo/registry/src/index.crates.io-6f17d22bba15001f/floem-winit-0.29.4/src/event_loop.rs:249:9
  42: floem::app::Application::run
             at /home/moveax41h/.cargo/git/checkouts/floem-69eea0a757d1e3ee/3160d2a/src/app.rs:144:17
  43: vault::main
             at ./src/main.rs:287:2
  44: core::ops::function::FnOnce::call_once
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

UPDATE: This seems to occur when attempting to add a new record of any type. I am using rust 1.79.0 in this case, and this was done on Fedora 38 VM.

dominikwilkowski commented 1 month ago

Nice find. Thank you @tcullum-rh Will fix tomorrow