Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cmd): nil pointer dereference in
PrintProgressBarsOnEvents
We now call on `o.Instance()` to get access to the underlying dataset methods (at the lib level). However, this leads to a `nil pointer dereference` error, when we use the CLI to interact with the qri node over http rpc. `o.Instance()` first calls `o.Init()`, which creates and sets up an instance if we don't currently have one using `lib.NewInstance`. When using the CLI to interact with a qri node via http rpc, however, `lib.NewInstance` returns early after setting up an `HTTPClient` in `inst.http`, so we route any CLI calls to the running qri node. `o.Init()` continues, but expects an instance with a `bus`, so it can pass the bus to `PrintProgressBarOnEvents`, which gives feedback to the user via progress bars. This bus is nil, so when `PrintProgressBarOnEvents` tries to subscribe to events on the bus, we get the error in question. Because we will probably want to give users progress via http rpc at some point, rather than disabling this behavior via rpc, the current fix just guards against a nil bus before attempting to subscribe to any events.
- Loading branch information