apache / superset

Apache Superset is a Data Visualization and Data Exploration Platform
https://superset.apache.org/
Apache License 2.0
61.94k stars 13.57k forks source link

[SQL Lab] Cannot perform any query when change language #27367

Open guilhermefacanha opened 6 months ago

guilhermefacanha commented 6 months ago

Bug description

I'm using version 3.1.1

image

When I have superset configured in English, I can load tables, preview, and execute SQL without problems

image

When I switch to Portuguese language, I start getting not enough arguments for format string error in preview or any sql execution

Log

2024-03-02 00:39:11 Query 75: Executing 1 statement(s)
2024-03-02 00:39:11 2024-03-02 08:39:11,948:INFO:superset.sql_lab:Query 75: Executing 1 statement(s)
2024-03-02 00:39:11 Query 75: Set query to 'running'
2024-03-02 00:39:11 2024-03-02 08:39:11,948:INFO:superset.sql_lab:Query 75: Set query to 'running'
2024-03-02 00:39:12 SupersetErrorsException
2024-03-02 00:39:12 Traceback (most recent call last):
2024-03-02 00:39:12   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1823, in full_dispatch_request
2024-03-02 00:39:12     rv = self.dispatch_request()
2024-03-02 00:39:12   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1799, in dispatch_request
2024-03-02 00:39:12     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/flask_appbuilder/security/decorators.py", line 95, in wraps
2024-03-02 00:39:12     return f(self, *args, **kwargs)
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/superset/views/base_api.py", line 127, in wraps
2024-03-02 00:39:12     raise ex
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/superset/views/base_api.py", line 121, in wraps
2024-03-02 00:39:12     duration, response = time_function(f, self, *args, **kwargs)
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/superset/utils/core.py", line 1463, in time_function
2024-03-02 00:39:12     response = func(*args, **kwargs)
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/superset/views/base_api.py", line 93, in wraps
2024-03-02 00:39:12     return f(self, *args, **kwargs)
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/superset/utils/log.py", line 255, in wrapper
2024-03-02 00:39:12     value = f(*args, **kwargs)
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/superset/sqllab/api.py", line 407, in execute_sql_query
2024-03-02 00:39:12     command_result: CommandResult = command.run()
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/superset/commands/sql_lab/execute.py", line 121, in run
2024-03-02 00:39:12     raise ex
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/superset/commands/sql_lab/execute.py", line 103, in run
2024-03-02 00:39:12     status = self._run_sql_json_exec_from_scratch()
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/superset/commands/sql_lab/execute.py", line 161, in _run_sql_json_exec_from_scratch
2024-03-02 00:39:12     raise ex
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/superset/commands/sql_lab/execute.py", line 156, in _run_sql_json_exec_from_scratch
2024-03-02 00:39:12     return self._sql_json_executor.execute(
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/superset/sqllab/sql_json_executer.py", line 111, in execute
2024-03-02 00:39:12     raise SupersetErrorsException(
2024-03-02 00:39:12 superset.exceptions.SupersetErrorsException: [SupersetError(message='not enough arguments for format string', error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR: 'GENERIC_DB_ENGINE_ERROR'>, level=<ErrorLevel.ERROR: 'error'>, extra={'engine_name': 'PostgreSQL', 'issue_codes': [{'code': 1002, 'message': 'Issue 1002 - O banco de dados retornou um erro inesperado.'}]})]
2024-03-02 00:39:12 2024-03-02 08:39:12,063:WARNING:superset.views.base:SupersetErrorsException
2024-03-02 00:39:12 Traceback (most recent call last):
2024-03-02 00:39:12   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1823, in full_dispatch_request
2024-03-02 00:39:12     rv = self.dispatch_request()
2024-03-02 00:39:12   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1799, in dispatch_request
2024-03-02 00:39:12     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/flask_appbuilder/security/decorators.py", line 95, in wraps
2024-03-02 00:39:12     return f(self, *args, **kwargs)
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/superset/views/base_api.py", line 127, in wraps
2024-03-02 00:39:12     raise ex
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/superset/views/base_api.py", line 121, in wraps
2024-03-02 00:39:12     duration, response = time_function(f, self, *args, **kwargs)
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/superset/utils/core.py", line 1463, in time_function
2024-03-02 00:39:12     response = func(*args, **kwargs)
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/superset/views/base_api.py", line 93, in wraps
2024-03-02 00:39:12     return f(self, *args, **kwargs)
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/superset/utils/log.py", line 255, in wrapper
2024-03-02 00:39:12     value = f(*args, **kwargs)
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/superset/sqllab/api.py", line 407, in execute_sql_query
2024-03-02 00:39:12     command_result: CommandResult = command.run()
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/superset/commands/sql_lab/execute.py", line 121, in run
2024-03-02 00:39:12     raise ex
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/superset/commands/sql_lab/execute.py", line 103, in run
2024-03-02 00:39:12     status = self._run_sql_json_exec_from_scratch()
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/superset/commands/sql_lab/execute.py", line 161, in _run_sql_json_exec_from_scratch
2024-03-02 00:39:12     raise ex
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/superset/commands/sql_lab/execute.py", line 156, in _run_sql_json_exec_from_scratch
2024-03-02 00:39:12     return self._sql_json_executor.execute(
2024-03-02 00:39:12   File "/app/superset_home/.local/lib/python3.9/site-packages/superset/sqllab/sql_json_executer.py", line 111, in execute
2024-03-02 00:39:12     raise SupersetErrorsException(
2024-03-02 00:39:12 superset.exceptions.SupersetErrorsException: [SupersetError(message='not enough arguments for format string', error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR: 'GENERIC_DB_ENGINE_ERROR'>, level=<ErrorLevel.ERROR: 'error'>, extra={'engine_name': 'PostgreSQL', 'issue_codes': [{'code': 1002, 'message': 'Issue 1002 - O banco de dados retornou um erro inesperado.'}]})]

How to reproduce the bug

  1. Go to SQL Lab
  2. Make sure you can preview or execute SQL statement
  3. Change Language, I used Portuguese BR
  4. Reload page
  5. Neither preview or SQL execution works

Screenshots/recordings

No response

Superset version

3.1.1

Python version

3.9

Node version

I don't know

Browser

Firefox

Additional context

No response

Checklist

davidkestering commented 5 months ago

The same issue happens with me too! I am running version 4.0.0

desennalin commented 2 months ago

Same problem here in version 4, I had to switch back to English, do you want anything?

rusackas commented 2 months ago

@dosu-bot

dosubot[bot] commented 2 months ago

Hello, @rusackas! I'm here to help you with any issues you may have while waiting for a human maintainer. I can help you solve bugs, answer questions, and become a contributor. Let me know how I can assist you!

To resolve the "not enough arguments for format string" error in Apache Superset when switching the language to Portuguese (BR) and attempting to preview or execute SQL statements, you need to ensure that the translation strings in the messages.po file correctly match the placeholders used in the original English strings.

For example, there is a mismatch in the translation for the following message:

#: superset/commands/database/validate_sql.py:74
#, python-format
msgid ""
"%(validator)s was unable to check your query.\n"
"Please recheck your query.\n"
"Exception: %(ex)s"
msgstr ""
"%(validador)es não conseguiu verificar sua consulta.\n"
"Por favor revise sua consulta.\n"
"Exceção: %(ex)s"

The placeholder %(validator)s in the original message is incorrectly translated as %(validador)es in the Portuguese message. The correct translation should maintain the same placeholder names:

msgstr ""
"%(validator)s não conseguiu verificar sua consulta.\n"
"Por favor revise sua consulta.\n"
"Exceção: %(ex)s"

Ensure that all placeholders in the translated strings match the original placeholders exactly. This should resolve the "not enough arguments for format string" error [1].

To continue talking to Dosu, mention @dosu.