alixinne / hyperion.rs

Rust implementation of the Hyperion Ambient Lighting software
MIT License
10 stars 1 forks source link

Switch `--dump-config` returns `Error, 0: values must be emitted before tables` #5

Closed tuxuser closed 2 years ago

tuxuser commented 2 years ago

This error when trying to read config from db and also expecting human readble TOML output via --dump-config.

Using both commits:

commandline invocation: ./target/debug/hyperiond --dump-config -d ~/.hyperion/db/hyperion.db

Output:

± COLORBT_SHOW_HIDDEN=1 RUST_BACKTRACE=full ./target/debug/hyperiond --dump-config -d ~/.hyperion/db/hyperion.db
Error: 
   0: values must be emitted before tables

Location:
   /rustc/1.57.0/library/core/src/result.rs:1914

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   1: color_eyre::config::EyreHook::default::ha2b10c87eb2b3da1
      at /home/tuxuser/.cargo/registry/src/github.com-1ecc6299db9ec823/color-eyre-0.5.11/src/config.rs:1016
      1014 │     pub(crate) fn default(&self, error: &(dyn std::error::Error + 'static)) -> crate::Handler {
      1015 │         let backtrace = if lib_verbosity() != Verbosity::Minimal {
      1016 >             Some(backtrace::Backtrace::new())
      1017 │         } else {
      1018 │             None
   2: color_eyre::config::EyreHook::into_eyre_hook::{{closure}}::h30ad4038bcf58826
      at /home/tuxuser/.cargo/registry/src/github.com-1ecc6299db9ec823/color-eyre-0.5.11/src/config.rs:1070
      1068 │             + 'static,
      1069 │     > {
      1070 >         Box::new(move |e| Box::new(self.default(e)))
      1071 │     }
      1072 │ }
   3: eyre::capture_handler::hf7ad12ffb0bcefcb
      at /home/tuxuser/.cargo/registry/src/github.com-1ecc6299db9ec823/eyre-0.6.5/src/lib.rs:551
       549 │         .as_ref();
       550 │ 
       551 >     let mut handler = hook(error);
       552 │ 
       553 │     #[cfg(track_caller)]
   4: eyre::error::<impl eyre::Report>::from_std::hd935e64f96ba806d
      at /home/tuxuser/.cargo/registry/src/github.com-1ecc6299db9ec823/eyre-0.6.5/src/error.rs:90
        88 │ 
        89 │         // Safety: passing vtable that operates on the right type E.
        90 >         let handler = Some(crate::capture_handler(&error));
        91 │ 
        92 │         unsafe { Report::construct(error, vtable, handler) }
   5: eyre::error::<impl core::convert::From<E> for eyre::Report>::from::h54ab36d177286976
      at /home/tuxuser/.cargo/registry/src/github.com-1ecc6299db9ec823/eyre-0.6.5/src/error.rs:464
       462 │     #[cfg_attr(track_caller, track_caller)]
       463 │     fn from(error: E) -> Self {
       464 >         Report::from_std(error)
       465 │     }
       466 │ }
   6: <core::result::Result<T,F> as core::ops::try_trait::FromResidual<core::result::Result<core::convert::Infallible,E>>>::from_residual::h11483fc5e6dc3c24
      at /rustc/1.57.0/library/core/src/result.rs:1914
   7: hyperiond::run::{{closure}}::h697ca7346ef4dc97
      at /home/tuxuser/Development/personal/lgtv/hyperion/hyperion.rs/src/main.rs:58
        56 │     // Dump configuration if this was asked
        57 │     if opts.dump_config {
        58 >         print!("{}", config.to_string()?);
        59 │         return Ok(());
        60 │     }
   8: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h6c46cacf7eb1bcc6
      at /rustc/1.57.0/library/core/src/future/mod.rs:80
   9: tokio::park::thread::CachedParkThread::block_on::{{closure}}::h90e382ba19834e4a
      at /home/tuxuser/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.12.0/src/park/thread.rs:263
       261 │ 
       262 │         loop {
       263 >             if let Ready(v) = crate::coop::budget(|| f.as_mut().poll(&mut cx)) {
       264 │                 return Ok(v);
       265 │             }
  10: tokio::coop::with_budget::{{closure}}::he0ab9a520b313cf9
      at /home/tuxuser/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.12.0/src/coop.rs:106
       104 │         let _guard = ResetGuard { cell, prev };
       105 │ 
       106 >         f()
       107 │     })
       108 │ }
  11: std::thread::local::LocalKey<T>::try_with::hd7310bf8dbd6ec8d
      at /rustc/1.57.0/library/std/src/thread/local.rs:399
  12: std::thread::local::LocalKey<T>::with::h198970fbbd7731fb
      at /rustc/1.57.0/library/std/src/thread/local.rs:375
  13: tokio::coop::with_budget::h831320107823800a
      at /home/tuxuser/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.12.0/src/coop.rs:99
        97 │     }
        98 │ 
        99 >     CURRENT.with(move |cell| {
       100 │         let prev = cell.get();
       101 │ 
  14: tokio::coop::budget::h6a8faedd8a4fdc5a
      at /home/tuxuser/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.12.0/src/coop.rs:76
        74 │ #[inline(always)]
        75 │ pub(crate) fn budget<R>(f: impl FnOnce() -> R) -> R {
        76 >     with_budget(Budget::initial(), f)
        77 │ }
        78 │ 
  15: tokio::park::thread::CachedParkThread::block_on::hd3f261bbf661b69c
      at /home/tuxuser/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.12.0/src/park/thread.rs:263
       261 │ 
       262 │         loop {
       263 >             if let Ready(v) = crate::coop::budget(|| f.as_mut().poll(&mut cx)) {
       264 │                 return Ok(v);
       265 │             }
  16: tokio::runtime::enter::Enter::block_on::h953be7dfa59116b9
      at /home/tuxuser/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.12.0/src/runtime/enter.rs:151
       149 │ 
       150 │             let mut park = CachedParkThread::new();
       151 >             park.block_on(f)
       152 │         }
       153 │ 
  17: tokio::runtime::thread_pool::ThreadPool::block_on::h5b533fdef1d51e24
      at /home/tuxuser/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.12.0/src/runtime/thread_pool/mod.rs:77
        75 │     {
        76 │         let mut enter = crate::runtime::enter(true);
        77 >         enter.block_on(future).expect("failed to park thread")
        78 │     }
        79 │ }
  18: tokio::runtime::Runtime::block_on::h0f9d09219537eb5d
      at /home/tuxuser/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.12.0/src/runtime/mod.rs:463
       461 │                 Kind::CurrentThread(exec) => exec.block_on(future),
       462 │                 #[cfg(feature = "rt-multi-thread")]
       463 >                 Kind::ThreadPool(exec) => exec.block_on(future),
       464 │             }
       465 │         }
  19: hyperiond::main::he880ed14205e9bc5
      at /home/tuxuser/Development/personal/lgtv/hyperion/hyperion.rs/src/main.rs:253
       251 │         .enable_all()
       252 │         .build()?;
       253 >     rt.block_on(run(opts))
       254 │ }
  20: core::ops::function::FnOnce::call_once::h6a958c2ff15fc2a1
      at /rustc/1.57.0/library/core/src/ops/function.rs:227
  21: std::sys_common::backtrace::__rust_begin_short_backtrace::ha4a18d8c66594778
      at /rustc/1.57.0/library/std/src/sys_common/backtrace.rs:123
  22: std::rt::lang_start::{{closure}}::h16d579df5c4f95dc
      at /rustc/1.57.0/library/std/src/rt.rs:146
  23: std::rt::lang_start_internal::h8366be35fc5c8ffb
      at <unknown source file>:<unknown line>
  24: std::rt::lang_start::h7462bf10acf95871
      at /rustc/1.57.0/library/std/src/rt.rs:145
  25: main<unknown>
      at <unknown source file>:<unknown line>
  26: __libc_start_main<unknown>
      at <unknown source file>:<unknown line>
  27: _start<unknown>
      at <unknown source file>:<unknown line>

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.

DB: hyperion_db.zip

alixinne commented 2 years ago

I don't get the issue with the current master, which has 219949e merged in. I do get an error because the file device isn't supported currently.

As for https://github.com/tuxuser/hyperion.rs/commit/f4efcc3ae1dd290c30b74296391d280a4763035a this error "makes sense" if you've changed the schema. TOML is picky when it comes to ordering tables and dictionaries, which may require reordering fields and/or using custom serialization logic (see https://github.com/alexcrichton/toml-rs/commit/79fc6c3fcbc2e77d25e18d5ef5bcd160ff9c900a)

tuxuser commented 2 years ago

Okay thx!

A stub FileDevice implementation can be found here btw: https://github.com/tuxuser/hyperion.rs/tree/feature/device%2Ffile

You should be able to verify the issue that way.

alixinne commented 2 years ago

I can't reproduce it with the master branch and the DB you provided (it's using the updated schema), but this seems to fix the issue with the schema update:

diff --git a/src/models/instance.rs b/src/models/instance.rs
index 38a6c4f3..7f374bfb 100644
--- a/src/models/instance.rs
+++ b/src/models/instance.rs
@@ -422,11 +422,11 @@ impl Default for MatrixLedConfig {
 #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize, Validate)]
 #[serde(default, rename_all = "camelCase", deny_unknown_fields)]
 pub struct LedConfig {
+    pub led_blacklist: Vec<u32>,
     #[validate]
     pub classic: ClassicLedConfig,
     #[validate]
     pub matrix: MatrixLedConfig,
-    pub led_blacklist: Vec<u32>,
 }

 #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Validate)]
tuxuser commented 2 years ago

That indeed fixed it, cheers ;)