berkeley-dsep-infra / datahub

JupyterHubs for use by Berkeley enrolled students
https://docs.datahub.berkeley.edu
BSD 3-Clause "New" or "Revised" License
63 stars 39 forks source link

500: Internal Server Error on Canvas login #3556

Closed dsconnell closed 2 years ago

dsconnell commented 2 years ago

Bug description

After I authorize login via canvas, I get a 500 : Internal Server Error.

Environment & setup

How to reproduce

  1. Go to https://datahub.berkeley.edu/
  2. Click 'Log in to continue'
  3. Click 'Authorize'
  4. See 500 : Internal Server Error
balajialg commented 2 years ago

@dsconnell I am not able to replicate this error. Is this your home directory? Can you also try logging in again using a different browser?

dsconnell commented 2 years ago

@balajialg Yes that should be my home directory. I get the same error in Chrome and Safari.

balajialg commented 2 years ago

@dsconnell That's weird! I am able to log in to your home directory and launch a python notebook. I am not sure what the issue is considering that it is not replicable.

FWIW, Can you clear your cache and try again? Try launching Data 8 hub using your calnet credentials - https://data8.datahub.berkeley.edu/?

dsconnell commented 2 years ago

@balajialg Before and after clearing my cache I got the same error launching the Data 8 hub. However, I discovered that https://publichealth.datahub.berkeley.edu/ works okay for me! I'm an admin there, if that matters

felder commented 2 years ago

@dsconnell another thing that might be worth trying is using a completely different browser + private/incognito mode for that browser.

Just to make super sure that there isn't some weird thing in the history or cache. I know you indicated you cleared your cache, but still worth trying!

kmaccuish commented 2 years ago

I have the same issue!

ryanlovett commented 2 years ago

@kmaccuish @dsconnell Can you both please try again and let us know how it goes? We just made an update to datahub that may fix this.

ryanlovett commented 2 years ago

Possibly related error:

[I 2022-08-12 06:48:55.718 JupyterHub user:297] Creating new group canvas::1505569::student for user [omitted]
[E 2022-08-12 06:48:55.727 JupyterHub web:1789] Uncaught exception GET /hub/oauth_callback?code=712[snip]&state=eyJ[snip] (10.0.0.38)
    HTTPServerRequest(protocol='https', host='datahub.berkeley.edu', method='GET', uri='/hub/oauth_callback?code=712[snip]&state=eyJ[snip]', version='HTTP/1.1', remote_ip='10.0.0.38')
    Traceback (most recent call last):
      File "/usr/local/lib/python3.9/site-packages/tornado/web.py", line 1704, in _execute
        result = await result
      File "/usr/local/lib/python3.9/site-packages/oauthenticator/oauth2.py", line 231, in get
        user = await self.login_user()
      File "/usr/local/lib/python3.9/site-packages/jupyterhub/handlers/base.py", line 811, in login_user
        user = await self.auth_to_user(authenticated)
      File "/usr/local/lib/python3.9/site-packages/jupyterhub/handlers/base.py", line 791, in auth_to_user
        user.sync_groups(group_names)
      File "/usr/local/lib/python3.9/site-packages/jupyterhub/user.py", line 306, in sync_groups
        self.db.commit()
      File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 1435, in commit
        self._transaction.commit(_to_root=self.future)
      File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 829, in commit
        self._prepare_impl()
      File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 808, in _prepare_impl
        self.session.flush()
      File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 3367, in flush
        self._flush(objects)
      File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 3507, in _flush
        transaction.rollback(_capture_exception=True)
      File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
        compat.raise_(
      File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
        raise exception
      File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 3467, in _flush
        flush_context.execute()
      File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/unitofwork.py", line 456, in execute
        rec.execute(self)
      File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/unitofwork.py", line 630, in execute
        util.preloaded.orm_persistence.save_obj(
      File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/persistence.py", line 245, in save_obj
        _emit_insert_statements(
      File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/persistence.py", line 1238, in _emit_insert_statements
        result = connection._execute_20(
      File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1631, in _execute_20
        return meth(self, args_10style, kwargs_10style, execution_options)
      File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/elements.py", line 325, in _execute_on_connection
        return connection._execute_clauseelement(
      File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1498, in _execute_clauseelement
        ret = self._execute_context(
      File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1862, in _execute_context
        self._handle_dbapi_exception(
      File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 2043, in _handle_dbapi_exception
        util.raise_(
      File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
        raise exception
      File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1819, in _execute_context
        self.dialect.do_execute(
      File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 732, in do_execute
        cursor.execute(statement, parameters)
    sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) UNIQUE constraint failed: groups.name
    [SQL: INSERT INTO groups (name) VALUES (?)]
    [parameters: ('canvas::1497305::student',)]
    (Background on this error at: https://sqlalche.me/e/14/gkpj)

[W 2022-08-12 06:48:55.728 JupyterHub base:1313] Rolling back session due to database error (sqlite3.IntegrityError) UNIQUE constraint failed: groups.name
    [SQL: INSERT INTO groups (name) VALUES (?)]
    [parameters: ('canvas::1497305::student',)]
    (Background on this error at: https://sqlalche.me/e/14/gkpj)
[E 2022-08-12 06:48:55.731 JupyterHub log:181] {
      "X-Scheme": "https",
      "X-Real-Ip": "10.0.0.38",
      "X-Forwarded-Server": "autohttps-78bcdddfd-k2c2j",
      "X-Forwarded-Proto": "https,http",
      "X-Forwarded-Port": "443,80",
      "X-Forwarded-Host": "datahub.berkeley.edu",
      "X-Forwarded-For": "10.0.0.38,::ffff:10.20.23.33",
      "Referer": "https://bcourses.berkeley.edu/login/oauth2/confirm",
      "Cookie": "oauthenticator-state=[secret]",
      "Accept-Language": "en-US,en;q=0.9",
      "Accept-Encoding": "gzip, deflate, br",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
      "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Safari/605.1.15",
      "Host": "datahub.berkeley.edu",
      "Connection": "close"
    }
dsconnell commented 2 years ago

It worked! Thank you!

kmaccuish commented 2 years ago

Also worked for me! Thank you!

On Fri, Aug 12, 2022 at 8:52 AM dsconnell @.***> wrote:

It worked! Thank you!

— Reply to this email directly, view it on GitHub https://github.com/berkeley-dsep-infra/datahub/issues/3556#issuecomment-1213263133, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQDEXSYFT5PPEIOH4JR2GTDVYZXNBANCNFSM56GWOZVA . You are receiving this because you were mentioned.Message ID: @.***>

-- Kelsey MacCuish, MPH (she/her/hers) Epidemiology & Biostatistics 2022 University of California, Berkeley | School of Public Health @.*** | 310-463-1330

balajialg commented 2 years ago

Great, Thanks!