baolong281 / jupyter-copilot

GitHub Copilot extension for JupyterLab
Other
20 stars 2 forks source link

404 errors when trying to sign in with GitHub #16

Open ogrisel opened 1 month ago

ogrisel commented 1 month ago

I just installed the extension via Jupyter lab's internal extension manager, the refreshed the page (or even restarted Jupyter lab).

Then I tried to sign in via cmd-shift-c "Copilot: Sign in with GitHub" but nothing happened.

[I 2024-09-18 18:48:53.748 ServerApp] Kernel started: a2e737f7-1cba-4e1c-8754-193c2c0b9108
[W 2024-09-18 18:48:59.152 ServerApp] 404 POST /jupyter-copilot/login?1726678139131 (78538d9711ce4fdb9f1f4a66ca9cf7f0@127.0.0.1) 17.75ms referer=http://localhost:8888/lab/workspaces/auto-0/tree/Untitled.ipynb
[W 2024-09-18 18:49:01.969 ServerApp] 404 GET /jupyter-copilot/ws?path=Untitled.ipynb (78538d9711ce4fdb9f1f4a66ca9cf7f0@127.0.0.1) 4.88ms referer=None

The rest of Jupyter lab seems functional. I am running version 4.2.5.

baolong281 commented 1 month ago

Hi I'm trying to reproduce this on the same version but I am unable to. After installing with the extension manager and restarting JupyterLab the issue goes away for me. Does running jupyter server extension list show that the server extension is active?

m-rossi commented 1 month ago

Same for me. jupyter server extension list shows

Config dir: C:\Users\USER\.jupyter

Config dir: C:\Users\USER\Python\envs\copilot\etc\jupyter
...
    jupyter_copilot enabled
    - Validating jupyter_copilot...
      jupyter_copilot 0.1.3 ok
...
baolong281 commented 1 month ago

Hi @m-rossi Are you using this with JupyterHub or something similar? If you don't mind could you share the output of jupyter lab --debug if you have the time? Thanks!

m-rossi commented 1 month ago

Quick update: The initial test I did on my company computer (as the company pays for GitHub Copilot), there I got the 404. Then I just tried my private computer and it worked immediately.

So my guess is the problem I see (and maybe also @ogrisel) is related to some proxy-issue. May @ogrisel can report back and if its a different problem I will open a separate issue.

ogrisel commented 1 month ago

I have no proxy on this computer (macOS laptop). I use it at home. There is no special network configuration either.

ogrisel commented 1 month ago
$ jupyter server extension list
Config dir: /Users/ogrisel/.jupyter

Config dir: /Users/ogrisel/miniforge3/envs/dev/etc/jupyter
    jupyter_lsp enabled
    - Validating jupyter_lsp...
      jupyter_lsp 2.2.5 OK
    jupyter_copilot enabled
    - Validating jupyter_copilot...
      jupyter_copilot 0.1.3 OK
    jupyter_server_terminals enabled
    - Validating jupyter_server_terminals...
      jupyter_server_terminals 0.5.3 OK
    jupyterlab enabled
    - Validating jupyterlab...
      jupyterlab 4.2.5 OK
    jupyterlab_code_formatter enabled
    - Validating jupyterlab_code_formatter...
      jupyterlab_code_formatter 3.0.2 OK
    notebook_shim enabled
    - Validating notebook_shim...
      notebook_shim  OK

Config dir: /usr/local/etc/jupyter

I am using Firefox, but I just tried with chrome and got the same 404 error on the HTTP POST.

ogrisel commented 1 month ago

I uninstalled and reinstalled the extension either via the command line or the extension manager and restarted Jupyter lab each time and I still got the same error. I did not install JupyterHub.

YongcaiHuang commented 1 month ago

same 404 error shows, even in a new env with only jupyterlab and jupyter-copilot installed

baolong281 commented 1 month ago

I'm really sorry that it isn't working for any of you—my best guess is that the API handlers aren't being registered for some reason. I've tried fresh installs on Mac and Linux but I still can't track down this error. I've made a new release (link) that has some more logging in the browser and terminal that may help with debugging this :+1:

hlpureboy commented 5 days ago

I'm also encountering a 404 error, which appears to be caused by the API route not being registered properly. To solve this, I manually registered the route during JupyterLab startup, and it successfully resolved the error.

from jupyter_copilot import _load_jupyter_server_extension
from jupyter_server.serverapp import ServerApp

if __name__ == "__main__":
    app = ServerApp.instance()

    # Configure ServerApp to allow all IP addresses and listen on the specified port
    app.ip = "0.0.0.0"  # Allow access from all IP addresses
    app.port = 8000  # Use port 8000
    app.open_browser = False  # Prevent the browser from opening automatically
    app.allow_root = True

    # Initialize the ServerApp instance and load extensions
    app.initialize()
    _load_jupyter_server_extension(app)

    # Start the application
    app.start()