Skip to content

Lox Distributor not properly parsing empty ResourceDiff

After trying a deployment of the lox distributor with no resources allocated to it (#19 (closed)), the distributor crashed when trying to marshall the received json from the rdsys backend into a ResourceDiff struct.

I got the following error:

$ RUST_BACKTRACE=1 ./bin/lox-distributor conf/lox-config.json 
Listening on 127.0.0.1:8001
thread 'tokio-runtime-worker' panicked at 'called `Option::unwrap()` on a `None` value', crates/lox-distributor/src/main.rs:91:44
stack backtrace:
   0: rust_begin_unwind
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
   1: core::panicking::panic_fmt
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
   2: core::panicking::panic
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:117:5
   3: lox_distributor::main::{{closure}}::{{closure}}
   4: tokio::runtime::task::raw::poll
   5: tokio::runtime::scheduler::multi_thread::worker::Context::run_task
   6: tokio::runtime::task::raw::poll
   7: tokio::runtime::task::UnownedTask<S>::run

And the received json looked like this:

{
    "new": {
        "obfs4": null,
        "scramblesuit": []
    },
    "changed": null,
    "gone": null,
    "full_update": true
}

I suspect the problem lies with the list of obfs4 bridges being null rather than an empty list []. The difference between obfs4 and scramblesuit here is that the lox distributor was configured to receive obfs4 only but requested both obfs4 and scramblesuit bridges.