anitab-org / mentorship-backend

Mentorship System is an application that matches women in tech to mentor each other, on career development, through 1:1 relations during a certain period of time. This is the backend of this system.
https://mentorship-backend-temp.herokuapp.com/
GNU General Public License v3.0
196 stars 449 forks source link

500 Internal Server Error #1101

Closed isabelcosta closed 3 years ago

isabelcosta commented 3 years ago

Describe the bug

The main development server is erroring w/ 500

To Reproduce

Steps to reproduce the behavior:

  1. Go to https://mentorship-backend-temp.herokuapp.com/
  2. See 500 Internal Server Error

Expected behavior

Screenshots

image

Additional context

I recently merged this PR, I did not test and assumed it would be fine, because it was coverage dependency. I thought this was only used in tests. Check latest commits here https://github.com/anitab-org/mentorship-backend/commits/develop

Should I revert them 🤔 not sure how the latest could have done that. I suspect it is an heroku thing 🤔

Logs on Heroku ``` 2021-05-16T00:12:50.790306+00:00 heroku[router]: at=info method=GET path="/" host=mentorship-backend-temp.herokuapp.com request_id=c5125532-5c3b-4d5c-a84d-eee38c33065c fwd="86.159.96.187" dyno=web.1 connect=0ms service=21ms status=500 bytes=244 protocol=https 2021-05-16T00:12:50.788806+00:00 app[web.1]: [2021-05-16 00:12:50 +0000] [11] [ERROR] Error handling request / 2021-05-16T00:12:50.788817+00:00 app[web.1]: Traceback (most recent call last): 2021-05-16T00:12:50.788817+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 134, in handle 2021-05-16T00:12:50.788818+00:00 app[web.1]: self.handle_request(listener, req, client, addr) 2021-05-16T00:12:50.788818+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 175, in handle_request 2021-05-16T00:12:50.788819+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response) 2021-05-16T00:12:50.788826+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 2309, in __call__ 2021-05-16T00:12:50.788826+00:00 app[web.1]: return self.wsgi_app(environ, start_response) 2021-05-16T00:12:50.788826+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 2295, in wsgi_app 2021-05-16T00:12:50.788826+00:00 app[web.1]: response = self.handle_exception(e) 2021-05-16T00:12:50.788827+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask_restx/api.py", line 639, in error_router 2021-05-16T00:12:50.788827+00:00 app[web.1]: return original_handler(e) 2021-05-16T00:12:50.788828+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1741, in handle_exception 2021-05-16T00:12:50.788828+00:00 app[web.1]: reraise(exc_type, exc_value, tb) 2021-05-16T00:12:50.788828+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise 2021-05-16T00:12:50.788829+00:00 app[web.1]: raise value 2021-05-16T00:12:50.788829+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app 2021-05-16T00:12:50.788830+00:00 app[web.1]: response = self.full_dispatch_request() 2021-05-16T00:12:50.788830+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1808, in full_dispatch_request 2021-05-16T00:12:50.788830+00:00 app[web.1]: self.try_trigger_before_first_request_functions() 2021-05-16T00:12:50.788831+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1855, in try_trigger_before_first_request_functions 2021-05-16T00:12:50.788831+00:00 app[web.1]: func() 2021-05-16T00:12:50.788831+00:00 app[web.1]: File "/app/run.py", line 45, in create_tables 2021-05-16T00:12:50.788832+00:00 app[web.1]: db.create_all() 2021-05-16T00:12:50.788832+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 1094, in create_all 2021-05-16T00:12:50.788832+00:00 app[web.1]: self._execute_for_all_tables(app, bind, 'create_all') 2021-05-16T00:12:50.788833+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 1086, in _execute_for_all_tables 2021-05-16T00:12:50.788833+00:00 app[web.1]: op(bind=self.get_engine(app, bind), **extra) 2021-05-16T00:12:50.788833+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 1017, in get_engine 2021-05-16T00:12:50.788834+00:00 app[web.1]: return connector.get_engine() 2021-05-16T00:12:50.788834+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 594, in get_engine 2021-05-16T00:12:50.788834+00:00 app[web.1]: self._engine = rv = self._sa.create_engine(sa_url, options) 2021-05-16T00:12:50.788835+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 1027, in create_engine 2021-05-16T00:12:50.788835+00:00 app[web.1]: return sqlalchemy.create_engine(sa_url, **engine_opts) 2021-05-16T00:12:50.788836+00:00 app[web.1]: File "", line 2, in create_engine 2021-05-16T00:12:50.788836+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/sqlalchemy/util/deprecations.py", line 298, in warned 2021-05-16T00:12:50.788836+00:00 app[web.1]: return fn(*args, **kwargs) 2021-05-16T00:12:50.788836+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/sqlalchemy/engine/create.py", line 522, in create_engine 2021-05-16T00:12:50.788837+00:00 app[web.1]: entrypoint = u._get_entrypoint() 2021-05-16T00:12:50.788837+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/sqlalchemy/engine/url.py", line 653, in _get_entrypoint 2021-05-16T00:12:50.788837+00:00 app[web.1]: cls = registry.load(name) 2021-05-16T00:12:50.788838+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 344, in load 2021-05-16T00:12:50.788838+00:00 app[web.1]: "Can't load plugin: %s:%s" % (self.group, name) 2021-05-16T00:12:50.788838+00:00 app[web.1]: sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:postgres 2021-05-16T00:12:50.789010+00:00 app[web.1]: 10.1.52.100 - - [16/May/2021:00:12:50 +0000] "GET / HTTP/1.1" 500 0 "-" "-" 2021-05-16T00:12:51.032647+00:00 app[web.1]: [2021-05-16 00:12:51 +0000] [10] [ERROR] Error handling request /favicon.ico 2021-05-16T00:12:51.032650+00:00 app[web.1]: Traceback (most recent call last): 2021-05-16T00:12:51.032651+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 134, in handle 2021-05-16T00:12:51.032652+00:00 app[web.1]: self.handle_request(listener, req, client, addr) 2021-05-16T00:12:51.032652+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 175, in handle_request 2021-05-16T00:12:51.032652+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response) 2021-05-16T00:12:51.032653+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 2309, in __call__ 2021-05-16T00:12:51.032653+00:00 app[web.1]: return self.wsgi_app(environ, start_response) 2021-05-16T00:12:51.032653+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 2295, in wsgi_app 2021-05-16T00:12:51.032653+00:00 app[web.1]: response = self.handle_exception(e) 2021-05-16T00:12:51.032654+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask_restx/api.py", line 639, in error_router 2021-05-16T00:12:51.032654+00:00 app[web.1]: return original_handler(e) 2021-05-16T00:12:51.032654+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1741, in handle_exception 2021-05-16T00:12:51.032655+00:00 app[web.1]: reraise(exc_type, exc_value, tb) 2021-05-16T00:12:51.032655+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise 2021-05-16T00:12:51.032655+00:00 app[web.1]: raise value 2021-05-16T00:12:51.032656+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app 2021-05-16T00:12:51.032656+00:00 app[web.1]: response = self.full_dispatch_request() 2021-05-16T00:12:51.032656+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1808, in full_dispatch_request 2021-05-16T00:12:51.032656+00:00 app[web.1]: self.try_trigger_before_first_request_functions() 2021-05-16T00:12:51.032657+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1855, in try_trigger_before_first_request_functions 2021-05-16T00:12:51.032657+00:00 app[web.1]: func() 2021-05-16T00:12:51.032657+00:00 app[web.1]: File "/app/run.py", line 45, in create_tables 2021-05-16T00:12:51.032658+00:00 app[web.1]: db.create_all() 2021-05-16T00:12:51.032658+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 1094, in create_all 2021-05-16T00:12:51.032658+00:00 app[web.1]: self._execute_for_all_tables(app, bind, 'create_all') 2021-05-16T00:12:51.032658+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 1086, in _execute_for_all_tables 2021-05-16T00:12:51.032658+00:00 app[web.1]: op(bind=self.get_engine(app, bind), **extra) 2021-05-16T00:12:51.032659+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 1017, in get_engine 2021-05-16T00:12:51.032659+00:00 app[web.1]: return connector.get_engine() 2021-05-16T00:12:51.032659+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 594, in get_engine 2021-05-16T00:12:51.032659+00:00 app[web.1]: self._engine = rv = self._sa.create_engine(sa_url, options) 2021-05-16T00:12:51.032659+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 1027, in create_engine 2021-05-16T00:12:51.032659+00:00 app[web.1]: return sqlalchemy.create_engine(sa_url, **engine_opts) 2021-05-16T00:12:51.032660+00:00 app[web.1]: File "", line 2, in create_engine 2021-05-16T00:12:51.032660+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/sqlalchemy/util/deprecations.py", line 298, in warned 2021-05-16T00:12:51.032660+00:00 app[web.1]: return fn(*args, **kwargs) 2021-05-16T00:12:51.032660+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/sqlalchemy/engine/create.py", line 522, in create_engine 2021-05-16T00:12:51.032661+00:00 app[web.1]: entrypoint = u._get_entrypoint() 2021-05-16T00:12:51.032661+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/sqlalchemy/engine/url.py", line 653, in _get_entrypoint 2021-05-16T00:12:51.032661+00:00 app[web.1]: cls = registry.load(name) 2021-05-16T00:12:51.032661+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 344, in load 2021-05-16T00:12:51.032662+00:00 app[web.1]: "Can't load plugin: %s:%s" % (self.group, name) 2021-05-16T00:12:51.032666+00:00 app[web.1]: sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:postgres 2021-05-16T00:12:51.032823+00:00 app[web.1]: 10.1.52.100 - - [16/May/2021:00:12:51 +0000] "GET /favicon.ico HTTP/1.1" 500 0 "-" "-" 2021-05-16T00:12:51.033490+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=mentorship-backend-temp.herokuapp.com request_id=578e82e1-ea94-4ebf-899c-2f19fe4bba12 fwd="86.159.96.187" dyno=web.1 connect=0ms service=21ms status=500 bytes=244 protocol=https ```
isabelcosta commented 3 years ago

@anitab-org/mentorship-maintainers Not sure, if I should revert the latest commit 🤔 if this is even a problem with the app

isabelcosta commented 3 years ago

I ran the app locally with the latest commit and this did not happen 🤔

image

isabelcosta commented 3 years ago

lol I really like stack overflow sometimes https://stackoverflow.com/a/64698899

I just googled the main error sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:postgres and found the error.

I changed the environment variable from:

DB_TYPE='postgres'

to:

DB_TYPE='postgresql'

Nailed it ✅

devkapilbansal commented 3 years ago

@isabelcosta probably the same happens here https://github.com/anitab-org/mentorship-backend/pull/1005#issuecomment-812510786