Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't use root logger #1990

Merged
merged 1 commit into from
Feb 1, 2023
Merged

fix: don't use root logger #1990

merged 1 commit into from
Feb 1, 2023

Conversation

Khrol
Copy link
Contributor

@Khrol Khrol commented Jan 31, 2023

Description

When the exception is logged it might cause another exception:

2023-01-31 11:09:00,239:ERROR:superset.views.base:_log() got an unexpected keyword argument 'exc_info'
Traceback (most recent call last):
  File "/opt/superset/lib/python3.9/site-packages/flask_appbuilder/api/__init__.py", line 109, in wraps
    return f(self, *args, **kwargs)
  File "/opt/superset/lib/python3.9/site-packages/superset/views/base_api.py", line 113, in wraps
    raise ex
  File "/opt/superset/lib/python3.9/site-packages/superset/views/base_api.py", line 110, in wraps
    duration, response = time_function(f, self, *args, **kwargs)
  File "/opt/superset/lib/python3.9/site-packages/superset/utils/core.py", line 1524, in time_function
    response = func(*args, **kwargs)
  File "/opt/superset/lib/python3.9/site-packages/superset/utils/log.py", line 245, in wrapper
    value = f(*args, **kwargs)
  File "/opt/superset/lib/python3.9/site-packages/superset/databases/api.py", line 601, in table_extra_metadata
    payload = database.db_engine_spec.extra_table_metadata(
  File "/opt/superset/lib/python3.9/site-packages/superset/db_engine_specs/presto.py", line 927, in extra_table_metadata
    Any, cls.get_create_view(database, schema_name, table_name)
  File "/opt/superset/lib/python3.9/site-packages/superset/db_engine_specs/presto.py", line 951, in get_create_view
    cls.execute(cursor, sql)
  File "/opt/superset/lib/python3.9/site-packages/superset/db_engine_specs/base.py", line 1261, in execute
    raise cls.get_dbapi_mapped_exception(ex)
  File "/opt/superset/lib/python3.9/site-packages/superset/db_engine_specs/base.py", line 1259, in execute
    cursor.execute(query)
  File "/opt/superset/lib/python3.9/site-packages/trino/dbapi.py", line 439, in execute
    result = self._query.execute()
  File "/opt/superset/lib/python3.9/site-packages/trino/client.py", line 765, in execute
    self._result.rows += self.fetch()
  File "/opt/superset/lib/python3.9/site-packages/trino/client.py", line 780, in fetch
    status = self._request.process(response)
  File "/opt/superset/lib/python3.9/site-packages/trino/client.py", line 581, in process
    raise self._process_error(response["error"], response.get("id"))
trino.exceptions.TrinoUserError: TrinoUserError(type=USER_ERROR, name=NOT_SUPPORTED, message="line 1:1: Relation 'asdf' is a table, not a view", query_id=20230131_110859_18306_tzku9)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/superset/lib/python3.9/site-packages/flask/app.py", line 1517, in full_dispatch_request
    rv = self.dispatch_request()
  File "/opt/superset/lib/python3.9/site-packages/flask/app.py", line 1503, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/opt/superset/lib/python3.9/site-packages/flask_appbuilder/security/decorators.py", line 89, in wraps
    return f(self, *args, **kwargs)
  File "/opt/superset/lib/python3.9/site-packages/superset/databases/decorators.py", line 66, in wraps
    return f(self, database, table_name_parsed, schema_name_parsed)
  File "/opt/superset/lib/python3.9/site-packages/flask_appbuilder/api/__init__.py", line 115, in wraps
    logging.exception(e)
  File "/opt/Python-3.9.16/lib/python3.9/logging/__init__.py", line 2072, in exception
    error(msg, *args, exc_info=exc_info, **kwargs)
  File "/opt/Python-3.9.16/lib/python3.9/logging/__init__.py", line 2064, in error
    root.error(msg, *args, **kwargs)
  File "/opt/Python-3.9.16/lib/python3.9/logging/__init__.py", line 1475, in error
    self._log(ERROR, msg, args, **kwargs)
TypeError: _log() got an unexpected keyword argument 'exc_info'

ADDITIONAL INFORMATION

  • Has associated issue:
  • Is CRUD MVC related.
  • Is Auth, RBAC security related.
  • Changes the security db schema.
  • Introduces new feature
  • Removes existing feature

When the exception is logged it might cause another exception:

```
2023-01-31 11:09:00,239:ERROR:superset.views.base:_log() got an unexpected keyword argument 'exc_info'
Traceback (most recent call last):
  File "/opt/superset/lib/python3.9/site-packages/flask_appbuilder/api/__init__.py", line 109, in wraps
    return f(self, *args, **kwargs)
  File "/opt/superset/lib/python3.9/site-packages/superset/views/base_api.py", line 113, in wraps
    raise ex
  File "/opt/superset/lib/python3.9/site-packages/superset/views/base_api.py", line 110, in wraps
    duration, response = time_function(f, self, *args, **kwargs)
  File "/opt/superset/lib/python3.9/site-packages/superset/utils/core.py", line 1524, in time_function
    response = func(*args, **kwargs)
  File "/opt/superset/lib/python3.9/site-packages/superset/utils/log.py", line 245, in wrapper
    value = f(*args, **kwargs)
  File "/opt/superset/lib/python3.9/site-packages/superset/databases/api.py", line 601, in table_extra_metadata
    payload = database.db_engine_spec.extra_table_metadata(
  File "/opt/superset/lib/python3.9/site-packages/superset/db_engine_specs/presto.py", line 927, in extra_table_metadata
    Any, cls.get_create_view(database, schema_name, table_name)
  File "/opt/superset/lib/python3.9/site-packages/superset/db_engine_specs/presto.py", line 951, in get_create_view
    cls.execute(cursor, sql)
  File "/opt/superset/lib/python3.9/site-packages/superset/db_engine_specs/base.py", line 1261, in execute
    raise cls.get_dbapi_mapped_exception(ex)
  File "/opt/superset/lib/python3.9/site-packages/superset/db_engine_specs/base.py", line 1259, in execute
    cursor.execute(query)
  File "/opt/superset/lib/python3.9/site-packages/trino/dbapi.py", line 439, in execute
    result = self._query.execute()
  File "/opt/superset/lib/python3.9/site-packages/trino/client.py", line 765, in execute
    self._result.rows += self.fetch()
  File "/opt/superset/lib/python3.9/site-packages/trino/client.py", line 780, in fetch
    status = self._request.process(response)
  File "/opt/superset/lib/python3.9/site-packages/trino/client.py", line 581, in process
    raise self._process_error(response["error"], response.get("id"))
trino.exceptions.TrinoUserError: TrinoUserError(type=USER_ERROR, name=NOT_SUPPORTED, message="line 1:1: Relation 'asdf' is a table, not a view", query_id=20230131_110859_18306_tzku9)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/superset/lib/python3.9/site-packages/flask/app.py", line 1517, in full_dispatch_request
    rv = self.dispatch_request()
  File "/opt/superset/lib/python3.9/site-packages/flask/app.py", line 1503, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/opt/superset/lib/python3.9/site-packages/flask_appbuilder/security/decorators.py", line 89, in wraps
    return f(self, *args, **kwargs)
  File "/opt/superset/lib/python3.9/site-packages/superset/databases/decorators.py", line 66, in wraps
    return f(self, database, table_name_parsed, schema_name_parsed)
  File "/opt/superset/lib/python3.9/site-packages/flask_appbuilder/api/__init__.py", line 115, in wraps
    logging.exception(e)
  File "/opt/Python-3.9.16/lib/python3.9/logging/__init__.py", line 2072, in exception
    error(msg, *args, exc_info=exc_info, **kwargs)
  File "/opt/Python-3.9.16/lib/python3.9/logging/__init__.py", line 2064, in error
    root.error(msg, *args, **kwargs)
  File "/opt/Python-3.9.16/lib/python3.9/logging/__init__.py", line 1475, in error
    self._log(ERROR, msg, args, **kwargs)
TypeError: _log() got an unexpected keyword argument 'exc_info'
```
@Khrol Khrol changed the title Don't use root logger Fix: don't use root logger Jan 31, 2023
@Khrol Khrol changed the title Fix: don't use root logger fix: don't use root logger Jan 31, 2023
@codecov
Copy link

codecov bot commented Jan 31, 2023

Codecov Report

Merging #1990 (3a29e43) into master (dcb32c7) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #1990   +/-   ##
=======================================
  Coverage   78.13%   78.13%           
=======================================
  Files          71       71           
  Lines        8612     8612           
=======================================
  Hits         6729     6729           
  Misses       1883     1883           
Flag Coverage Δ
python 78.13% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
flask_appbuilder/api/__init__.py 96.31% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Owner

@dpgaspar dpgaspar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug, thank you!

@dpgaspar dpgaspar merged commit 1e1c354 into dpgaspar:master Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants