shuttle-hq / synth

The Declarative Data Generator
https://www.getsynth.com/
Apache License 2.0
1.37k stars 108 forks source link

DateTime format %+ with poisson panics #429

Open connorjburton opened 1 year ago

connorjburton commented 1 year ago

Describe the bug Using the %+ format with a poisson parameter causes a panic

To Reproduce Steps to reproduce the behavior:

  1. Schema (if applicable)
    {
    "type": "array",
    "length": 1,
    "content": {
    "type": "object",
    "date": {
      "type": "series",
      "format": "%+",
      "poisson": {
        "start": "2001-07-08T00:34:60.026490+09:30",
        "rate": "10m"
      }
    }
    }
    }
  2. See error
    #0 0.339 thread 'main' panicked at 'a Display implementation returned an error unexpectedly: Error', /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/alloc/src/string.rs:2537:14
    #0 0.339 stack backtrace:
    #0 0.348    0:     0x5591ea081f90 - std::backtrace_rs::backtrace::libunwind::trace::hc67583789182810a
    #0 0.348                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
    #0 0.348    1:     0x5591ea081f90 - std::backtrace_rs::backtrace::trace_unsynchronized::h1938dfa1aa97f8ae
    #0 0.348                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
    #0 0.348    2:     0x5591ea081f90 - std::sys_common::backtrace::_print_fmt::hc27f3d4fb7d08e50
    #0 0.348                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/std/src/sys_common/backtrace.rs:65:5
    #0 0.348    3:     0x5591ea081f90 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h0efab7bfe941d4d0
    #0 0.348                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/std/src/sys_common/backtrace.rs:44:22
    #0 0.350    4:     0x5591ea0aa90e - core::fmt::write::h816cc3b1bcaa0f63
    #0 0.350                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/core/src/fmt/mod.rs:1208:17
    #0 0.350    5:     0x5591ea07b955 - std::io::Write::write_fmt::h33dba8a681e64ab5
    #0 0.350                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/std/src/io/mod.rs:1682:15
    #0 0.350    6:     0x5591ea081d55 - std::sys_common::backtrace::_print::ha3a4aa724c6dd991
    #0 0.350                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/std/src/sys_common/backtrace.rs:47:5
    #0 0.350    7:     0x5591ea081d55 - std::sys_common::backtrace::print::h871c005525ccf4a5
    #0 0.350                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/std/src/sys_common/backtrace.rs:34:9
    #0 0.350    8:     0x5591ea08386f - std::panicking::default_hook::{{closure}}::h424788f485e3b8e1
    #0 0.350                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/std/src/panicking.rs:267:22
    #0 0.350    9:     0x5591ea0835aa - std::panicking::default_hook::ha4cff4743b1eccf9
    #0 0.350                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/std/src/panicking.rs:286:9
    #0 0.350   10:     0x5591ea083f6c - std::panicking::rust_panic_with_hook::hc5412f99bf75d7f4
    #0 0.350                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/std/src/panicking.rs:688:13
    #0 0.350   11:     0x5591ea083d07 - std::panicking::begin_panic_handler::{{closure}}::hda18b8c75e63ca29
    #0 0.350                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/std/src/panicking.rs:579:13
    #0 0.350   12:     0x5591ea08243c - std::sys_common::backtrace::__rust_end_short_backtrace::h41096ce078932c3e
    #0 0.350                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/std/src/sys_common/backtrace.rs:137:18
    #0 0.350   13:     0x5591ea083a22 - rust_begin_unwind
    #0 0.350                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/std/src/panicking.rs:575:5
    #0 0.350   14:     0x5591e958a763 - core::panicking::panic_fmt::hf5120a639c3767d3
    #0 0.350                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/core/src/panicking.rs:65:14
    #0 0.350   15:     0x5591e958aa23 - core::result::unwrap_failed::hfbaee9f21e9ebc55
    #0 0.350                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/core/src/result.rs:1791:5
    #0 0.350   16:     0x5591e965580e - <synth_core::graph::series::SeriesFormatter<S> as synth_gen::generator::Generator>::next::h02625a5e320e38de
    #0 0.350   17:     0x5591e97becea - <synth_gen::generator::try::TryOnce<G> as synth_gen::generator::Generator>::next::h350a979c43dc9304
    #0 0.350   18:     0x5591e9666767 - <synth_core::graph::series::SeriesNode as synth_gen::generator::Generator>::next::hbfa65097e8cd0c7a
    #0 0.350   19:     0x5591e97e225e - <synth_core::graph::Graph as synth_gen::generator::Generator>::next::h30ec3f6e5df5805e
    #0 0.351   20:     0x5591e969a737 - <synth_gen::generator::Concatenate<Left,Right> as synth_gen::generator::Generator>::next::h7ac9b71955857793
    #0 0.351   21:     0x5591e969a8d8 - <synth_gen::generator::Concatenate<Left,Right> as synth_gen::generator::Generator>::next::h7ac9b71955857793
    #0 0.351   22:     0x5591e96cb979 - <synth_gen::generator::Chain<G> as synth_gen::generator::Generator>::next::h9f02af69b35d90f9
    #0 0.351   23:     0x5591e96ce23e - <synth_gen::generator::Brace<BG,G,EG> as synth_gen::generator::Generator>::next::he1e0de48d351339c
    #0 0.351   24:     0x5591e95ea096 - <synth_core::graph::object::ObjectNode as synth_gen::generator::Generator>::next::h5f8250c54dc17aea
    #0 0.351   25:     0x5591e97e2236 - <synth_core::graph::Graph as synth_gen::generator::Generator>::next::h30ec3f6e5df5805e
    #0 0.351   26:     0x5591e96cbfa7 - <synth_gen::generator::Repeat<G> as synth_gen::generator::Generator>::next::h18c60b8396d3dc5d
    #0 0.351   27:     0x5591e96cdee1 - <synth_gen::generator::Brace<BG,G,EG> as synth_gen::generator::Generator>::next::h6164cae722f24e32
    #0 0.351   28:     0x5591e97aa1a1 - <synth_gen::generator::try::AndThenTry<TG,F,O> as synth_gen::generator::Generator>::next::hd041aa24ad2e5c30
    #0 0.351   29:     0x5591e97e224a - <synth_core::graph::Graph as synth_gen::generator::Generator>::next::h30ec3f6e5df5805e
    #0 0.351   30:     0x5591e969a737 - <synth_gen::generator::Concatenate<Left,Right> as synth_gen::generator::Generator>::next::h7ac9b71955857793
    #0 0.351   31:     0x5591e96cb979 - <synth_gen::generator::Chain<G> as synth_gen::generator::Generator>::next::h9f02af69b35d90f9
    #0 0.351   32:     0x5591e96ce23e - <synth_gen::generator::Brace<BG,G,EG> as synth_gen::generator::Generator>::next::he1e0de48d351339c
    #0 0.351   33:     0x5591e95ea096 - <synth_core::graph::object::ObjectNode as synth_gen::generator::Generator>::next::h5f8250c54dc17aea
    #0 0.351   34:     0x5591e97e2236 - <synth_core::graph::Graph as synth_gen::generator::Generator>::next::h30ec3f6e5df5805e
    #0 0.351   35:     0x5591e96cebc0 - synth_gen::generator::Generator::complete::h66d1de1066a1f564
    #0 0.351   36:     0x5591e9653856 - synth::sampler::Sampler::sample_seeded::hd74301c29f45868b
    #0 0.351   37:     0x5591e95a5a61 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h511dc30a466168f6
    #0 0.351   38:     0x5591e95a64e3 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hf252e9c74cece437
    #0 0.352   39:     0x5591e95935fa - std::thread::local::LocalKey<T>::with::h2c9db70ab3a1a433
    #0 0.352   40:     0x5591e95a41ac - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h0a1a71ac04bbe7db
    #0 0.352   41:     0x5591e95959b5 - async_io::driver::block_on::h9eff5d5ac6e5e1ea
    #0 0.352   42:     0x5591e958c388 - async_global_executor::executor::block_on::hfbf38b0d74a76193
    #0 0.352   43:     0x5591e95934af - std::thread::local::LocalKey<T>::with::h10dc8a84c9472fd5
    #0 0.352   44:     0x5591e95938a1 - std::thread::local::LocalKey<T>::with::h89eca4c072d85689
    #0 0.352   45:     0x5591e959ff34 - async_std::task::builder::Builder::blocking::h2f899bd1d046013a
    #0 0.352   46:     0x5591e9593217 - synth::main::h206211c0f8419040
    #0 0.352   47:     0x5591e9593343 - std::sys_common::backtrace::__rust_begin_short_backtrace::h60a6891658e893ba
    #0 0.352   48:     0x5591e959335d - std::rt::lang_start::{{closure}}::h1c24ca765cf20089
    #0 0.352   49:     0x5591ea0753ac - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hebc86e6b8a80589c
    #0 0.352                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/core/src/ops/function.rs:606:13
    #0 0.352   50:     0x5591ea0753ac - std::panicking::try::do_call::h6dd205c801ee9563
    #0 0.352                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/std/src/panicking.rs:483:40
    #0 0.352   51:     0x5591ea0753ac - std::panicking::try::h6a305dcb41c05a6b
    #0 0.352                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/std/src/panicking.rs:447:19
    #0 0.352   52:     0x5591ea0753ac - std::panic::catch_unwind::hb2706f9f02af9e36
    #0 0.352                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/std/src/panic.rs:137:14
    #0 0.352   53:     0x5591ea0753ac - std::rt::lang_start_internal::{{closure}}::h2fb1f83a0dad9961
    #0 0.352                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/std/src/rt.rs:148:48
    #0 0.352   54:     0x5591ea0753ac - std::panicking::try::do_call::heef61f72d1ba7b16
    #0 0.352                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/std/src/panicking.rs:483:40
    #0 0.352   55:     0x5591ea0753ac - std::panicking::try::hdf4af242715689c0
    #0 0.352                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/std/src/panicking.rs:447:19
    #0 0.352   56:     0x5591ea0753ac - std::panic::catch_unwind::hb05b6f6482b28931
    #0 0.352                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/std/src/panic.rs:137:14
    #0 0.352   57:     0x5591ea0753ac - std::rt::lang_start_internal::h7c97b403cf78f112
    #0 0.352                                at /rustc/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/std/src/rt.rs:148:20
    #0 0.352   58:     0x5591e9593245 - main
    #0 0.352   59:     0x7f1dccdfad0a - __libc_start_main
    #0 0.352   60:     0x5591e958abbe - _start
    #0 0.352   61:                0x0 - <unknown>

Expected behavior Should generate date times in %+ format from 2001-07-08T00:34:60.026490+09:30 onwards

Screenshots N/A

Environment (please complete the following information):

Ran in docker with debian:latest image

Additional context Add any other context about the problem here. Dockerfile

FROM debian:latest AS generate
WORKDIR /gen
ENV PATH="/root/.local/bin:${PATH}"
ENV RUST_BACKTRACE=full
RUN bash
RUN apt-get update -y && apt-get install curl jq -y
RUN curl --proto "=https" --tlsv1.2 -sSL https://getsynth.com/install | sh -s -- --ci
COPY . .
RUN synth generate . --collection logs --size 100 --to json:./data/output.$(date +"%Y-%m-%d_%H-%M-%S").json

FROM scratch as generate-export
COPY --from=generate /gen/data /