Skip to content

Gateway not passing kernels and kernelspecs requests correctly with base_url #1549

@brianjball

Description

@brianjball

Description

base_url is not respected in gateway clients specifically for kernels and kernelspecs. Furthermore, an old bug fix for logo requests (#1111 ) also appears to have been undone. I suspect that this bug may be related to #1219 as well but would need someone more experienced than myself to confirm or deny. Logs can be found in the Context section below.

To my knowledge, the only workaround today is to use two env vars, JUPYTER_GATEWAY_KERNELSPECS_ENDPOINT and JUPYTER_GATEWAY_KERNELS_ENDPOINT. This will not fix the logo requests bug, though the system is still functional.

I am happy to contribute to a fix and will have a PR forthcoming shortly.

Reproduce

  1. Download the two files at the end of this section.
  2. Start the base server first: jupyter lab --config=jupyter_config-base.py
  3. Then start the second server: jupyter lab --config=jupyter_config-gateway.py
  4. Track the errors from the the second server. Specifically it will throw 404s on every kernel and kernelspec call. If you use your browser, it will also prevent you from choosing any kernel type so you can't proceed in running any notebook. Please see an example error log at the end of the Issue.

The logs from the running servers indicate that the base_url is being processed correctly on the second server, but when the request gets forwarded to the base server, it does not add it, resulting in the 404.

jupyter_config-base.py

c.NotebookApp.open_browser = False
c.ServerApp.token = ""
c.ServerApp.password = ""
c.ServerApp.base_url = "/notebook/test"
c.ServerApp.port = 8887

c.Application.log_level = 0

jupyter_config-gateway.py

import json

c.NotebookApp.open_browser = True
c.ServerApp.token = ""
c.ServerApp.password = ""
c.ServerApp.base_url = "/notebook/test"
c.ServerApp.port = 8888

c.GatewayClient.headers = json.dumps({"Origin": PROXY_URL, "Cookie": "_xsrf=XSRF", "X-XSRFToken": "XSRF"})
c.GatewayClient.url = "http://localhost:8887"
c.Application.log_level = 0

Expected behavior

I expect the calls to properly redirect for seamless functionality. Based on my understanding of the base_url functionality, it must match between the local and remote servers for other calls, so I would expect the same functionality here. If instead there is a different expectation, I am more than happy to be corrected.

Context

I hope the OS and browser versions don't matter, but for completeness, I'm running Chrome 139.0.7258.67 on Windows 11 and I can reproduce this bug with jupyter-server as recent as 2.16.0 (the current version at the time of this issue).

Command Line Output

logs.txt

Browser Output
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions