Skip to content

User.verify_code throws exception when user does not exist #1178

@adamrp

Description

@adamrp

these lines select the verification code that's stored in the database for the user so that it can be compared with the verification code supplied by the user on a password reset or user creation. Line 275 assumes that the user exists and throws an exception if it does not; we are seeing this error on the server:

Traceback (most recent call last):

  File "/home/qiita/.virtualenvs/qiita/lib/python2.7/site-packages/tornado/web.py", line 1141, in _when_complete
    callback()

  File "/home/qiita/.virtualenvs/qiita/lib/python2.7/site-packages/tornado/web.py", line 1162, in _execute_method
    self._when_complete(method(*self.path_args, **self.path_kwargs),

  File "/home/qiita/qiita_main/qiita_pet/handlers/auth_handlers.py", line 66, in get
    if User.verify_code(email, code, "create"):

  File "/home/qiita/qiita_main/qiita_db/user.py", line 275, in verify_code
    db_code = conn_handler.execute_fetchone(sql, (email,))[0]

TypeError: 'NoneType' object has no attribute '__getitem__'

We should check whether the execute_fetchone actually returned anything before trying to access index 0.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions