Skip to content
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

Cannot initialize extension in collaborative mode due to missing initials #302

Closed
ktaletsk opened this issue Jul 28, 2023 · 2 comments · Fixed by #316
Closed

Cannot initialize extension in collaborative mode due to missing initials #302

ktaletsk opened this issue Jul 28, 2023 · 2 comments · Fixed by #316
Labels
bug Something isn't working

Comments

@ktaletsk
Copy link

Description

The extension fails in collaborative mode in JupyterLab 3.6.3 spawned by JupyterHub.

Reproduce

  1. Install Jupyter AI extension in JupyterLab Docker image
  2. Spawn JupyterLab container with JupyterHub
  3. Observe the following message in Jupyter AI's UI
There seems to be a problem with the Chat backend, please look at the JupyterLab server logs or contact your administrator to correct this problem.
image
  1. In JupyterLab container logs, see the following
2023-07-28 04:07:34,802 - SingleUserLabApp - ERROR - Uncaught exception GET /user/<user email>/api/ai/chats?token=<some token> (<ip>)
HTTPServerRequest(protocol='https', host='<JupyterHub URL>', method='GET', uri='/user/<user email>/api/ai/chats?token=<some token> ', version='HTTP/1.1', remote_ip='<ip>')
Traceback (most recent call last):
  File "/opt/conda/lib/python3.9/site-packages/tornado/websocket.py", line 937, in _accept_connection
    open_result = handler.open(*handler.open_args, **handler.open_kwargs)
  File "/opt/conda/lib/python3.9/site-packages/jupyter_ai/handlers.py", line 137, in open
    current_user = self.get_chat_user().dict()
  File "/opt/conda/lib/python3.9/site-packages/jupyter_ai/handlers.py", line 117, in get_chat_user
    return ChatUser(**asdict(self.current_user))
  File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for ChatUser
initials
  none is not an allowed value (type=type_error.none.not_allowed)

Expected behavior

Extension loads

Context

  • Operating System and version: Linux Ubuntu 22.04
  • Browser and version: Edge 112
  • JupyterLab version: 3.6.3

Debugging

  1. Add self.log.info(self.current_user) into this line
  2. Output is
User(username='<user email>', name='<user email>', display_name='<user email>', initials=None, avatar_url=None, color=None)
  1. For whatever reason initials are not returned in my environment and the code is expecting them to not be none
  2. I implemented a simple fix to calculate initials based on the username
user = self.current_user
user.initials = user.name[0].capitalize()

if collaborative:
    return ChatUser(**asdict(user))

and it resolved my issue.

@ktaletsk ktaletsk added the bug Something isn't working label Jul 28, 2023
@welcome
Copy link

welcome bot commented Jul 28, 2023

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@wolffiex
Copy link

The linked patch didn't work for me, I had to do this

            chat_user_kwargs = { 
                # set in case IdentityProvider doesn't return initials, e.g. 
                # JupyterHub (#302) 
                **asdict(self.current_user), 
                "initials": initials, 
            }
            return ChatUser(**chat_user_kwargs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants