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

Admin user names are parsed as integers when they correspond to numbers #589

Open
jtpio opened this issue Jun 23, 2020 · 2 comments
Open
Labels
bug Something isn't working

Comments

@jtpio
Copy link
Contributor

jtpio commented Jun 23, 2020

Bug description

Expected behaviour

It should be possible to add admin users identified as numbers via tljh-config.

Actual behaviour

Doing so yields an error (see traceback below)

How to reproduce

  1. Use LTIAuthenticator
  2. Add a user as admin: sudo tljh-config add-item users.admin "9" (users are numbers with LTI)
  3. Reload the hub with tljh-config reload hub
  4. JupyterHub fails to reload with the following stack trace:
Jun 23 17:11:14 jhub3 python3[442251]: [E 2020-06-23 17:11:14.041 JupyterHub app:2718]
Jun 23 17:11:14 jhub3 python3[442251]:     Traceback (most recent call last):
Jun 23 17:11:14 jhub3 python3[442251]:       File "/opt/tljh/hub/lib/python3.8/site-packages/jupyterhub/app.py", line 2715, in launch_instance_async
Jun 23 17:11:14 jhub3 python3[442251]:         await self.initialize(argv)
Jun 23 17:11:14 jhub3 python3[442251]:       File "/opt/tljh/hub/lib/python3.8/site-packages/jupyterhub/app.py", line 2286, in initialize
Jun 23 17:11:14 jhub3 python3[442251]:         await self.init_users()
Jun 23 17:11:14 jhub3 python3[442251]:       File "/opt/tljh/hub/lib/python3.8/site-packages/jupyterhub/app.py", line 1614, in init_users
Jun 23 17:11:14 jhub3 python3[442251]:         admin_users = [
Jun 23 17:11:14 jhub3 python3[442251]:       File "/opt/tljh/hub/lib/python3.8/site-packages/jupyterhub/app.py", line 1615, in <listcomp>
Jun 23 17:11:14 jhub3 python3[442251]:         self.authenticator.normalize_username(name)
Jun 23 17:11:14 jhub3 python3[442251]:       File "/opt/tljh/hub/lib/python3.8/site-packages/jupyterhub/auth.py", line 325, in normalize_username
Jun 23 17:11:14 jhub3 python3[442251]:         username = username.lower()
Jun 23 17:11:14 jhub3 python3[442251]:     AttributeError: 'int' object has no attribute 'lower'

Your personal set up

  • OS: Ubuntu
  • Version: 20.04
  • Configuration: TLJH with LTIAuthenticator

Workaround

A workaround is to specify the list of admin users explicitely as strings in the JupyterHub config with:

c.Authenticator.admin_users = { '9' }
@jtpio jtpio added the bug Something isn't working label Jun 23, 2020
@jtpio
Copy link
Contributor Author

jtpio commented Jun 23, 2020

It looks like this is coming from the parse_value function which automatically converts the string to the appropriate type:

def parse_value(value_str):
"""Parse a value string"""
if value_str is None:
return value_str
if re.match(r'^\d+$', value_str):
return int(value_str)
elif re.match(r'^\d+\.\d*$', value_str):
return float(value_str)
elif value_str.lower() == 'true':
return True
elif value_str.lower() == 'false':
return False
else:
# it's a string
return value_str

@consideRatio
Copy link
Member

consideRatio commented Oct 25, 2021

I've seen the equivalent issue for the helm CLI resolved as a --set-string alongside the more commonly used --set.

I'm not sure how to go about handling this situation as it's a bit too convoluted in my mind if we would track what value that the user tries to set or add an item to... Well... Unless we have a schema for it at least, hmmm...

I've opened #725 to track the need for adding a JSONSchema for the tljh configuration file.

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

No branches or pull requests

2 participants