Skip to content

RuntimeWarning: Expected to see HubAuthenticatedHandler #488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fcollonval opened this issue Apr 22, 2021 · 6 comments · Fixed by jupyterhub/jupyterhub#3437
Closed

RuntimeWarning: Expected to see HubAuthenticatedHandler #488

fcollonval opened this issue Apr 22, 2021 · 6 comments · Fixed by jupyterhub/jupyterhub#3437
Assignees
Labels

Comments

@fcollonval
Copy link
Member

Description

We have updated to JupyterLab 3 (and jupyter_server). And we are now seeing the following warning in the logs for all api handlers when starting JupyterLab user servers (using local process spawner):

python3.7/site-packages/jupyter_server/base/handlers.py:131: RuntimeWarning: Expected to see HubAuthenticatedHandler in <class 'jupyter_server.base.handlers.FileFindHandler'>.mro()

Expected behavior

The warning is raising questions about the security of our infrastructure. Is it expected?

Context

  • Operating System and version: Debian 9 (stretch)
  • Jupyter Server version:
    • jupyter_client 6.1.12 pyhd8ed1ab_0 conda-forge
    • jupyter_core 4.7.1 py37h89c1867_0 conda-forge
    • jupyter_server 1.6.4 py37h89c1867_0 conda-forge
    • jupyterhub 1.4.0 py37h89c1867_0 conda-forge
    • jupyterhub-base 1.4.0 py37h89c1867_0 conda-forge
    • jupyterhub-singleuser 1.4.0 py37h89c1867_0 conda-forge
      jupyterlab 3.0.14 pyhd8ed1ab_0 conda-forge
@fcollonval fcollonval added the bug label Apr 22, 2021
@minrk minrk self-assigned this Apr 22, 2021
@minrk
Copy link
Contributor

minrk commented Apr 22, 2021

Thanks for the report! I'm looking into it.

To alleviate security concerns while I do, exactly how hub auth gets patched into Jupyter Server handlers changed in a recent version of jupyterhub to be more efficient, so it patches the base handler class once on startup instead of repeatedly patching Handler instances on every request. This warning is the fallback where the one-time patch wasn't applied to a given handler, and the old way is taken instead (it is not removed to protect against exactly this eventuality), so auth should not be affected, but it will be a bit less efficient (and not any less efficient than it was a few months ago). This occurs when a handler isn't derived from the app's BaseHandler class.

I have been able to reproduce this, and it occurs if you are using NotebookApp with jupyterlab as an Extension, since the jupyterlab extension uses the jupyter_server handlers, and only the notebook base handler is patched at startup.

Short answer, if you are using juptyerlab, set:

c.Spawner.cmd = ["jupyter-labhub"]

and the warning should go away because the old NotebookApp shouldn't be used anymore, everything ought to use jupyter_server and you should be set.

The fix belongs in JupyterHub, to make sure we patch jupyter_server and notebook base handlers, because mixing the two is actually a valid thing to do, which I didn't fully realize. I'll transfer this issue to the jupyterhub repo, where the fix should reside.

I'll also update the warning to include a reassurance that auth is still applied, just at a slightly different time to avoid causing undue stress.

@minrk
Copy link
Contributor

minrk commented Apr 22, 2021

Oop, I don't seem to have permissions to transfer issues cross-org. No problem, I'll just link the PR to this issue.

@blink1073
Copy link
Contributor

That's odd, I verified that you are an owner on the org.

@minrk
Copy link
Contributor

minrk commented Apr 22, 2021

From the docs:

You can only transfer issues between repositories owned by the same user or organization account. You can't transfer an issue from a private repository to a public repository.

so it apparently can't be done. I could swear I've done it before, but who knows? 🤷

Not a big deal. jupyterhub/jupyterhub#3437 should fix it.

@blink1073
Copy link
Contributor

Ahh, Meeseeks can do it though: jupyter/notebook#5996 (comment)

@fcollonval
Copy link
Member Author

Thanks a lot @minrk for the reassuring detailed answer.

minrk added a commit to minrk/jupyterhub that referenced this issue May 12, 2021
…rver and notebook

and clarify warning when a base handler isn't patched that auth is still being applied

- reorganize patch steps into functions for easier re-use
- patch notebook and jupyter_server handlers if they are already imported
- run patch after initialize to ensure extensions have done their importing before we check what's present
- apply class-level patch even when instance-level patch is happening to avoid triggering patch on every request

This change isn't as big as it looks, because it's mostly moving some re-used code to a couple of functions.

closes jupyter-server/jupyter_server#488

Signed-off-by: Min RK <[email protected]>
yuvipanda added a commit to yuvipanda/datahub that referenced this issue Jul 2, 2021
jupyter-server/jupyter_server#488
might be causing our culling and missing defaultUrl issues.
I do see the warning mentioned there present here.

I think we're running ServerApp but we aren't 100% sure which
is causing problems.

Ref berkeley-dsep-infra#2452
Ref berkeley-dsep-infra#2460
shaneknapp pushed a commit to berkeley-dsep-infra/biology-user-image that referenced this issue Sep 6, 2024
jupyter-server/jupyter_server#488
might be causing our culling and missing defaultUrl issues.
I do see the warning mentioned there present here.

I think we're running ServerApp but we aren't 100% sure which
is causing problems.

Ref berkeley-dsep-infra/datahub#2452
Ref berkeley-dsep-infra/datahub#2460
shaneknapp pushed a commit to berkeley-dsep-infra/eecs-user-image that referenced this issue Sep 11, 2024
jupyter-server/jupyter_server#488
might be causing our culling and missing defaultUrl issues.
I do see the warning mentioned there present here.

I think we're running ServerApp but we aren't 100% sure which
is causing problems.

Ref berkeley-dsep-infra/datahub#2452
Ref berkeley-dsep-infra/datahub#2460
shaneknapp pushed a commit to berkeley-dsep-infra/julia-user-image that referenced this issue Sep 12, 2024
jupyter-server/jupyter_server#488
might be causing our culling and missing defaultUrl issues.
I do see the warning mentioned there present here.

I think we're running ServerApp but we aren't 100% sure which
is causing problems.

Ref berkeley-dsep-infra/datahub#2452
Ref berkeley-dsep-infra/datahub#2460
shaneknapp pushed a commit to berkeley-dsep-infra/datahub-user-image that referenced this issue Sep 25, 2024
jupyter-server/jupyter_server#488
might be causing our culling and missing defaultUrl issues.
I do see the warning mentioned there present here.

I think we're running ServerApp but we aren't 100% sure which
is causing problems.

Ref berkeley-dsep-infra/datahub#2452
Ref berkeley-dsep-infra/datahub#2460
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants