upbound / up

The @upbound CLI
Apache License 2.0
49 stars 42 forks source link

ctx: Correctly handle errors on selection, including kubeconfig verification timeouts #558

Closed adamwg closed 3 weeks ago

adamwg commented 3 weeks ago

Description of your changes

Previously, if we hit an error in the onEnter function when a user selected an item, we would get stuck completely: the spinner would keep spinning forever. If we hit an error when listing items for a new screen, the error would be displayed but the user wouldn't be able to navigate.

Fix both issues by correctly handling the errors. In both cases, we re-enable the keymap and return the existing model, so the user can continue to navigate.

A glaring example of this issue was if we tried to select a context that was unreachable. We would time out trying to validate the kubeconfig and sit spinning forever. Add a 2 second timeout to the kubeconfig validation to ensure we don't spin for too long, even though we now won't get stuck forever.

I have:

How has this code been tested

Manual testing with unreachable disconnected spaces and spaces I don't have permission to access. Both cases would previously get stuck, and now don't.