Ramilito / kubectl.nvim

⎈ Streamline your Kubernetes management within Neovim—control and monitor your cluster seamlessly, all without leaving your coding environment.
Apache License 2.0
327 stars 9 forks source link

Errors when opening kubectl.nvim and changing views #360

Closed Elyviere closed 1 month ago

Elyviere commented 1 month ago

Describe the bug Errors upon opening kubectl and changing view (e.g. from Deployments to Pods). The error is the following:

 ¯¬ç  Error  16:02:02 msg_show.lua_error Error executing luv callback:
.../nvim/lazy/kubectl.nvim/lua/kubectl/actions/informer.lua:65: attempt to index field 'object' (a nil value)
stack traceback:
    .../nvim/lazy/kubectl.nvim/lua/kubectl/actions/informer.lua:65: in function 'process_event'
    .../nvim/lazy/kubectl.nvim/lua/kubectl/actions/informer.lua:163: in function 'process'
    .../share/nvim/lazy/kubectl.nvim/lua/kubectl/utils/loop.lua:32: in function <.../share/nvim/lazy/kubectl.nvim/lua/kubectl/utils/loop.lua:27>

Sometimes the following additional information is also in the stacktrace:

 ¯¬ç  Error  16:09:13 msg_show.lua_error Error executing luv callback:
.../nvim/lazy/kubectl.nvim/lua/kubectl/actions/informer.lua:65: attempt to index field 'object' (a nil value)
stack traceback:
    .../nvim/lazy/kubectl.nvim/lua/kubectl/actions/informer.lua:65: in function 'process_event'
    .../nvim/lazy/kubectl.nvim/lua/kubectl/actions/informer.lua:163: in function 'process'
    .../share/nvim/lazy/kubectl.nvim/lua/kubectl/utils/loop.lua:32: in function <.../share/nvim/lazy/kubectl.nvim/lua/kubectl/utils/loop.lua:27>
    [C]: in function 'nvim_set_option_value'
    ...re/nvim/lazy/kubectl.nvim/lua/kubectl/actions/layout.lua:18: in function 'set_buf_options'
    ...e/nvim/lazy/kubectl.nvim/lua/kubectl/actions/buffers.lua:299: in function 'buffer'
    ...e/nvim/lazy/kubectl.nvim/lua/kubectl/resourcebuilder.lua:48: in function 'display'
    ...e/nvim/lazy/kubectl.nvim/lua/kubectl/resourcebuilder.lua:360: in function 'view'
    .../lazy/kubectl.nvim/lua/kubectl/views/configmaps/init.lua:11: in function 'View'
    ...al/share/nvim/lazy/kubectl.nvim/lua/kubectl/mappings.lua:405: in function <...al/share/nvim/lazy/kubectl.nvim/lua/kubectl/mappings.lua:403>

Note that everything seems to work fine despite the error. All deployments and pods still show up in the list, navigation still works. It's unclear what the error relates to.

To Reproduce

  1. Use the following config in LazyVim:
    return {
    {
    "ramilito/kubectl.nvim",
    config = function()
      require("kubectl").setup({
        namespace = "your-namespace",
        namespace_fallback = { "your-namespace", "your-other-namespace" },
      })
    end,
    },
    }
  2. (Use a kubernetes user where you don't have access to view namespaces?)
  3. Open kubectl.nvim in neovim and the error should pop up
  4. Change view (e.g. change to Secrets by pressing '4') and the same error should pop up again

Environment (please complete the following information):

Additional context Last time I saw something similar it was due to the LazyVim dashboard, but that's not the case here. The error occurs also when opening kubectl.nvim while editing a file.

Ramilito commented 1 month ago

Thanks for the excellent issue as usual 🙏 I think I solved it, haven't experienced this myself but the error is from the informer and should only affect the live updates that happens, you can always refresh manually with gr. Added a check before processing the event but tbh, I'm not sure why it's empty, if you see obsolete information please let me know!