FitTrackee icon indicating copy to clipboard operation
FitTrackee copied to clipboard

[bug]

Open CYBERNEURONES opened this issue 6 months ago • 1 comments

Checklist

  • [x] Describe the bug.
  • [ ] Copy of the output/log.
  • [ ] Include your .env file.
  • [x] Steps to Reproduce
  • [ ] The exact command that failed. This is what you typed at the command line, including any options.
  • [x] FitTrackee version, this is reported by pip show fittrackee
  • [x] Operating System and Python Version
  • [ ] Installed Python packages

Describe the bug

Issue on OAUTH2.

Copy of the output/log

[SQL: SELECT oauth2_client.id AS oauth2_client_id, oauth2_client.user_id AS oauth2_client_user_id, oauth2_client.client_id AS oauth2_client_client_id, oauth2_client.client_secret AS oauth2_client_client_secret, oauth2_client.client_id_issued_at AS oauth2_client_client_id_issued_at, oauth2_client.client_secret_expires_at AS oauth2_client_client_secret_expires_at, oauth2_client.client_metadata AS oauth2_client_client_metadata FROM oauth2_client WHERE oauth2_client.client_id = %(client_id_1)s LIMIT %(param_1)s] [parameters: {'client_id_1': 'qDtMHZpLMWrv9sMip2NF8Nrw', 'param_1': 1}] (Background on this error at: https://sqlalche.me/e/20/e3q8)

Include the .env file

export APP_LOG=/home/farias/fittrackee/fittrackee.log export UPLOAD_FOLDER=/home/farias/fittrackee/uploads export DATABASE_URL=postgresql://fittrackee:fittrackeePW@localhost:5432/fittrackee export UI_URL=https://fit.cyber-neurones.org/

To Reproduce

No response

FitTrackee Version

v0.10.3

Python Version

3.11

FitTrackee installation method

From PyPI

Operating System

GNU/Linux

Python Packages

$ pip freeze alembic==1.15.2 async-timeout==5.0.1 attrs==25.3.0 Authlib==1.5.2 babel==2.17.0 bcrypt==4.3.0 blinker==1.9.0 CacheControl==0.14.3 certifi==2025.1.31 cffi==1.17.1 charset-normalizer==3.4.1 click==8.1.8 cryptography==44.0.2 Deprecated==1.2.18 dramatiq==1.17.1 dramatiq-abort==1.2.1 filelock==3.18.0 fitdecode==0.10.0 fittrackee==0.10.3 Flask==3.1.1 Flask-Bcrypt==1.0.1 flask-dramatiq==0.6.0 Flask-Limiter==3.12 Flask-Migrate==4.1.0 Flask-SQLAlchemy==3.1.1 gpxpy==1.6.2 greenlet==3.2.0 gunicorn==23.0.0 humanize==4.12.2 idna==3.10 itsdangerous==2.2.0 Jinja2==3.1.6 jsonschema==4.23.0 jsonschema-specifications==2024.10.1 limits==5.0.0 lxml==5.4.0 Mako==1.3.10 markdown-it-py==3.0.0 MarkupSafe==3.0.2 mdurl==0.1.2 msgpack==1.1.1 nh3==0.2.21 oauthlib==3.2.2 ordered-set==4.1.0 packaging==24.2 pillow==11.2.1 prometheus_client==0.21.1 psycopg2-binary==2.9.10 pycparser==2.22 Pygments==2.19.1 PyJWT==2.10.1 pyOpenSSL==25.1.0 pytz==2025.2 redis==5.2.1 referencing==0.36.2 requests==2.32.3 requests-oauthlib==2.0.0 rich==13.9.4 rpds-py==0.24.0 shortuuid==1.0.13 SQLAlchemy==2.0.41 staticmap==0.5.7 staticmap3==0.1.0 typing_extensions==4.13.2 ua-parser==1.0.1 ua-parser-builtins==0.18.0.post1 urllib3==2.4.0 Werkzeug==3.1.3 wrapt==1.17.2 xmltodict==0.14.2

CYBERNEURONES avatar Jun 22 '25 08:06 CYBERNEURONES

Hi,

Is it possible to have more information, such as the lines before the SQL error and the steps to reproduce the error? Thanks.

SamR1 avatar Jun 22 '25 11:06 SamR1

Hi,

Is it possible to have more information, such as the lines before the SQL error and the steps to reproduce the error? Thanks.

2025/06/21 19:13:58 - fittrackee - ERROR - Exception on /api/oauth/token [POST] Traceback (most recent call last): File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1963, in _exec_single_context self.dialect.do_execute( File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 943, in do_execute cursor.execute(statement, parameters) psycopg2.OperationalError: SSL connection has been closed unexpectedly

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/flask/app.py", line 1511, in wsgi_app response = self.full_dispatch_request() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/flask/app.py", line 919, in full_dispatch_request rv = self.handle_user_exception(e) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/flask/app.py", line 917, in full_dispatch_request rv = self.dispatch_request() ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/flask/app.py", line 902, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/fittrackee/oauth2/routes.py", line 626, in issue_token return authorization_server.create_token_response() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/authlib/oauth2/rfc6749/authorization_server.py", line 317, in create_token_response grant.validate_token_request() File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/authlib/oauth2/rfc6749/grants/refresh_token.py", line 106, in validate_token_request client = self._validate_request_client() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/authlib/oauth2/rfc6749/grants/refresh_token.py", line 39, in _validate_request_client client = self.authenticate_token_endpoint_client() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/authlib/oauth2/rfc6749/grants/base.py", line 76, in authenticate_token_endpoint_client client = self.server.authenticate_client( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/authlib/oauth2/rfc6749/authorization_server.py", line 118, in authenticate_client return self._client_auth(request, methods, endpoint) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/authlib/oauth2/rfc6749/authenticate_client.py", line 59, in call return self.authenticate(request, methods, endpoint) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/authlib/oauth2/rfc6749/authenticate_client.py", line 42, in authenticate client = func(self.query_client, request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/authlib/oauth2/rfc6749/authenticate_client.py", line 83, in authenticate_client_secret_post client = _validate_client(query_client, client_id, request.state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/authlib/oauth2/rfc6749/authenticate_client.py", line 110, in _validate_client client = query_client(client_id) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/authlib/integrations/flask_oauth2/authorization_server.py", line 64, in query_client return self._query_client(client_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/authlib/integrations/sqla_oauth2/functions.py", line 14, in query_client return q.filter_by(client_id=client_id).first() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/sqlalchemy/orm/query.py", line 2759, in first return self.limit(1)._iter().first() # type: ignore

                                              ^^^^^^^^^^^^^^^^^^^^^

File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2365, in execute return self._execute_internal( ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/sqlalchemy/orm/session.py", line 2251, in _execute_internal result: Result[Any] = compile_state_cls.orm_execute_statement( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/sqlalchemy/orm/context.py", line 306, in orm_execute_statement result = conn.execute( ^^^^^^^^^^^^^ File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1415, in execute return meth( ^^^^^ File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/sqlalchemy/sql/elements.py", line 523, in _execute_on_connection return connection._execute_clauseelement( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1637, in _execute_clauseelement ret = self._execute_context( ^^^^^^^^^^^^^^^^^^^^^^ File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1842, in _execute_context return self._exec_single_context( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1982, in _exec_single_context self._handle_dbapi_exception( File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2351, in _handle_dbapi_exception raise sqlalchemy_exception.with_traceback(exc_info[2]) from e File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1963, in _exec_single_context self.dialect.do_execute( File "/home/farias/fittrackee/fittrackee_venv/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 943, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) SSL connection has been closed unexpectedly

[SQL: SELECT oauth2_client.id AS oauth2_client_id, oauth2_client.user_id AS oauth2_client_user_id, oauth2_client.client_id AS oauth2_client_client_id, oauth2_client.client_secret AS oauth2_client_client_secret, oauth2_client.client_id_issued_at AS oauth2_client_client_id_issued_at, oauth2_client.client_secret_expires_at AS oauth2_client_client_secret_expires_at, oauth2_client.client_metadata AS oauth2_client_client_metadata FROM oauth2_client WHERE oauth2_client.client_id = %(client_id_1)s LIMIT %(param_1)s] [parameters: {'client_id_1': 'qDtMHZpLMWrv9sMip2NF8Nrw', 'param_1': 1}] (Background on this error at: https://sqlalche.me/e/20/e3q8)

CYBERNEURONES avatar Jun 23 '25 17:06 CYBERNEURONES

thanks for the log.

does the error only occur with this endpoint (/api/oauth/token [POST])?

SamR1 avatar Jun 25 '25 05:06 SamR1

I have change :

export DATABASE_URL=postgresql+psycopg2://fittrackee:fittrackeePW@localhost:5432/fittrackee

( same issue with DATABASE_URL=postgresql://fittrackee:fittrackeePW@localhost:5432/fittrackee )

I have also change on pg_hba.conf - /etc/postgresql/15/main/pg_hba.conf local all all trust local all all trust host all all 127.0.0.1/32 trust

I can connect :

psql fittrackee -U fittrackee --password

In /var/log/postgresql/postgresql-15-main.log I don't see error.

For the moment I don't understand where is the issue.

CYBERNEURONES avatar Jul 05 '25 11:07 CYBERNEURONES

Now issue is fixed with Python 3.13.

But it's not works due to opensteetmap.org :

staticmap3.staticmap - ERROR - request failed [None]: https://tile.openstreetmap.org/13/4234/2988.png

CYBERNEURONES avatar Jul 05 '25 12:07 CYBERNEURONES

Is the Static Map cache directory (STATICMAP_CACHE_DIR) writable?

SamR1 avatar Jul 06 '25 19:07 SamR1

The issue is fixed. I add STATICMAP_CACHE_DIR on my env.cfg.

CYBERNEURONES avatar Jul 07 '25 15:07 CYBERNEURONES

great!

SamR1 avatar Jul 09 '25 09:07 SamR1