Skip to content

[BUG] Empty username and/or password on token endpoint raises 500 server error #20

@coltonbh

Description

@coltonbh

Probably want to handle this more gracefully and send over a nicer response (invalid inputs).

Logs:

tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    | 10.0.1.163:55730 - "POST /api/v1/oauth/token HTTP/1.1" 500
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    | [2021-02-20 07:32:47 +0000] [11] [ERROR] Exception in ASGI application
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    | Traceback (most recent call last):
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |   File "/usr/local/lib/python3.7/site-packages/uvicorn/protocols/http/httptools_impl.py", line 396, in run_asgi
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |     result = await app(self.scope, self.receive, self.send)
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |   File "/usr/local/lib/python3.7/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in __call__
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |     return await self.app(scope, receive, send)
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |   File "/usr/local/lib/python3.7/site-packages/fastapi/applications.py", line 199, in __call__
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |     await super().__call__(scope, receive, send)
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |   File "/usr/local/lib/python3.7/site-packages/starlette/applications.py", line 111, in __call__
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |     await self.middleware_stack(scope, receive, send)
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |   File "/usr/local/lib/python3.7/site-packages/starlette/middleware/errors.py", line 181, in __call__
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |     raise exc from None
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |   File "/usr/local/lib/python3.7/site-packages/starlette/middleware/errors.py", line 159, in __call__
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |     await self.app(scope, receive, _send)
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |   File "/usr/local/lib/python3.7/site-packages/starlette/exceptions.py", line 82, in __call__
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |     raise exc from None
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |   File "/usr/local/lib/python3.7/site-packages/starlette/exceptions.py", line 71, in __call__
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |     await self.app(scope, receive, sender)
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |   File "/usr/local/lib/python3.7/site-packages/starlette/routing.py", line 566, in __call__
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |     await route.handle(scope, receive, send)
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |   File "/usr/local/lib/python3.7/site-packages/starlette/routing.py", line 227, in handle
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |     await self.app(scope, receive, send)
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |   File "/usr/local/lib/python3.7/site-packages/starlette/routing.py", line 41, in app
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |     response = await func(request)
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |   File "/usr/local/lib/python3.7/site-packages/fastapi/routing.py", line 202, in app
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |     dependant=dependant, values=values, is_coroutine=is_coroutine
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |   File "/usr/local/lib/python3.7/site-packages/fastapi/routing.py", line 148, in run_endpoint_function
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |     return await dependant.call(**values)
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |   File "/code/terachem_cloud/routes/oauth.py", line 52, in token
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |     scope=" ".join(form_data.scopes),
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |   File "pydantic/main.py", line 362, in pydantic.main.BaseModel.__init__
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    | pydantic.error_wrappers.ValidationError: 2 validation errors for OAuth2PasswordFlow
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    | username
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |   none is not an allowed value (type=type_error.none.not_allowed)
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    | password
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    |   none is not an allowed value (type=type_error.none.not_allowed)
tcc_web-server.1.zlr32ljkgjay@ip-172-16-1-207.us-west-2.compute.internal    | 10.0.1.163:55746 - "GET /.git/HEAD HTTP/1.1" 404

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions