UnifiedPush / gotify-dbus-rust

MIT License
0 stars 2 forks source link

SQLite crash on numeric token #1

Closed karmanyaahm closed 3 years ago

karmanyaahm commented 3 years ago

To reproduce the issue run this twice

dbus-send --session --dest=org.unifiedpush.Distributor.gotify --print-reply /org/unifiedpush/Distributor org.unifiedpush.Distributor1.Register string:com.test string:1234

The token can be anything(?) numeric I think

The backtrace:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: InvalidColumnType(1, "token", Integer)', /home/karmanyaahm/.cargo/registry/src/github.com-1ecc6299db9ec823/rusqlite-0.24.2/src/row.rs:258:23
stack backtrace:
   0: rust_begin_unwind
             at /rustc/881c1ac408d93bb7adaa3a51dabab9266e82eee8/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/881c1ac408d93bb7adaa3a51dabab9266e82eee8/library/core/src/panicking.rs:92:14
   2: core::result::unwrap_failed
             at /rustc/881c1ac408d93bb7adaa3a51dabab9266e82eee8/library/core/src/result.rs:1355:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/881c1ac408d93bb7adaa3a51dabab9266e82eee8/library/core/src/result.rs:1037:23
   4: rusqlite::row::Row::get_unwrap
             at /home/karmanyaahm/.cargo/registry/src/github.com-1ecc6299db9ec823/rusqlite-0.24.2/src/row.rs:258:9
   5: unifiedpush_gotify_lib::get_connections_with_token
             at ./src/lib.rs:36:20
   6: unifiedpush_gotify::registration::Distributor::register
             at ./src/registration.rs:37:27
   7: <unifiedpush_gotify::registration::Distributor as zbus::object_server::Interface>::call_mut
             at ./src/registration.rs:32:1
   8: zbus::object_server::ObjectServer::dispatch_method_call_try::{{closure}}::{{closure}}::{{closure}}
             at /home/karmanyaahm/.cargo/registry/src/github.com-1ecc6299db9ec823/zbus-2.0.0-beta.2/src/object_server.rs:567:32
   9: core::option::Option<T>::or_else
             at /rustc/881c1ac408d93bb7adaa3a51dabab9266e82eee8/library/core/src/option.rs:788:21
  10: zbus::object_server::ObjectServer::dispatch_method_call_try::{{closure}}::{{closure}}
             at /home/karmanyaahm/.cargo/registry/src/github.com-1ecc6299db9ec823/zbus-2.0.0-beta.2/src/object_server.rs:567:17
  11: scoped_tls::ScopedKey<T>::set
             at /home/karmanyaahm/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137:9
  12: zbus::object_server::ObjectServer::dispatch_method_call_try::{{closure}}
             at /home/karmanyaahm/.cargo/registry/src/github.com-1ecc6299db9ec823/zbus-2.0.0-beta.2/src/object_server.rs:565:13
  13: scoped_tls::ScopedKey<T>::set
             at /home/karmanyaahm/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137:9
  14: zbus::object_server::ObjectServer::dispatch_method_call_try
             at /home/karmanyaahm/.cargo/registry/src/github.com-1ecc6299db9ec823/zbus-2.0.0-beta.2/src/object_server.rs:564:9
  15: zbus::object_server::ObjectServer::dispatch_method_call
             at /home/karmanyaahm/.cargo/registry/src/github.com-1ecc6299db9ec823/zbus-2.0.0-beta.2/src/object_server.rs:580:15
  16: zbus::object_server::ObjectServer::dispatch_message
             at /home/karmanyaahm/.cargo/registry/src/github.com-1ecc6299db9ec823/zbus-2.0.0-beta.2/src/object_server.rs:603:17
  17: zbus::object_server::ObjectServer::try_handle_next
             at /home/karmanyaahm/.cargo/registry/src/github.com-1ecc6299db9ec823/zbus-2.0.0-beta.2/src/object_server.rs:621:13
  18: unifiedpush_gotify::registration::run
             at ./src/registration.rs:126:27
  19: unifiedpush_gotify::main
             at ./src/main.rs:64:5
  20: core::ops::function::FnOnce::call_once
             at /rustc/881c1ac408d93bb7adaa3a51dabab9266e82eee8/library/core/src/ops/function.rs:227:5
vurpo commented 3 years ago

Fixed in 506b4ee (it turns out the sqlite type for text is TEXT and not STRING, and it lets you store any type you want in the column if you try to use a type name that doesn't exist, like that). I think you might need to delete the database file and start again. I haven't figured out any database migration system to handle schema updates like this.