Skip to content

KeyError: 'namespace' in reflector.py #915

Description

@gioargyr

Bug description

I installed JupyterHub in my Kubernetes cluster using the official Helm chart. I have troubles in making it spawn a ComfyUI instance.
I checked the logs of the hub Pod and I see this error:

[E 2026-04-24 08:08:27.197 JupyterHub reflector:383] Error when watching resources, retrying in 0.2s
    Traceback (most recent call last):
      File "/usr/local/lib/python3.12/site-packages/kubespawner/reflector.py", line 343, in _watch_and_update
        resource["metadata"]["namespace"],
        ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
    KeyError: 'namespace'

I found there is the Role hub and no namespace resources are defined.
So, I edited the Role hub and I added namespace in the resources to be able to get, watch, and list.

After that, I repeated all the steps and I no longer have this error! Should such a change in the Role hub be permanent?

My 2 conflicting thoughts:

It's not the first time I try to launch a custom web service through JupyterHub, but it's the first time I get this error. So, it feels like this custom web service I am trying to launch is creating conflicts.
On the other hand, the problem and its solution seem very general and not related with the custom web service I am trying to launch. Also, even though I fix this error, I still have issues launching the ComfyUI custom web service.

I hope mentioning this issue will help either JupyterHub developers or users in the future.

How to reproduce

  1. Deploy JupyterHub using the official Helm chart
  2. Try to spawn a custom web service.

Expected behaviour

I expected hub Pod to be able to see namespaces

Actual behaviour

The hub Pod is not be able to see namespaces

Your personal set up

  • I deploy JupyterHub using the official Helm chart on a Kubernetes cluster
  • The cluster has 6 nodes and all of them are running Ubuntu 24.04
  • The Helm Chart Version is 4.3.2 and the App Version is 5.3.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions