AutumnSun1996 opened a new issue, #28145:
URL: https://github.com/apache/superset/issues/28145

   ### Bug description
   
   Cannot accesse 'Query history' page, and get empty list with this error:
   
   
![image](https://github.com/apache/superset/assets/20429502/6ee84b92-ff36-417f-9991-0d273547db91)
   
   the error comes from sql_parse.py. check the logs below.
   
   ### How to reproduce the bug
   
   Minimum sample:
   
   1. Start superset with following docker-compose.yml
   ```docker-compose
   version: "3.7"
   
   services:
     superset:
       image: apachesuperset.docker.scarf.sh/apache/superset:3.1.2
       volumes:
         - superset_home:/app/superset_home
       environment:
         SUPERSET_SECRET_KEY: secretkey
         SUPERSET_DB_URI: 
sqlite:///superset_home/superset.db?check_same_thread=false
         SUPERSET_CONFIG_PATH: /app/superset_home/superset_config.py
       ports:
         - 8088:8088
       command:
         - "sh"
         - "-c"
         - |-
           # allow sqlite for easier reproduce
           echo 'PREVENT_UNSAFE_DB_CONNECTIONS=False' > 
/app/superset_home/superset_config.py
           # init database
           superset db upgrade
           # init admin user
           superset fab create-admin --username admin --firstname Superset 
--lastname Admin --email ad...@superset.com --password admin
           # init roles
           superset init
           # run server
           /usr/bin/run-server.sh
   
   volumes:
     superset_home:
       external: false
   
   ```
   
   2. Go localhost:8088, login as admin/admin
   3. Add one database, can just use 
'sqlite:///superset_home/superset.db?check_same_thread=false'
   4. Goto SQL->SQLLab, run some queries.
   5. Goto SQL->Query hisory, and the error appears.
   
   
   ### Screenshots/recordings
   
   
![image](https://github.com/apache/superset/assets/20429502/6ee84b92-ff36-417f-9991-0d273547db91)
   
   
   ### Superset version
   
   3.1.2
   
   ### Python version
   
   3.10
   
   ### Node version
   
   Not applicable
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   tried both 3.1.2 and 4.0.0, and got same error with slightly different line 
numbers.
   
   logs from 3.1.2:
   ```log
   Traceback (most recent call last):
     File "/app/superset/views/base.py", line 252, in wraps
       return f(self, *args, **kwargs)
     File "/app/superset/views/base_api.py", line 487, in get_list_headless
       duration, response = time_function(super().get_list_headless, **kwargs)
     File "/app/superset/utils/core.py", line 1463, in time_function
       response = func(*args, **kwargs)
     File 
"/usr/local/lib/python3.10/site-packages/flask_appbuilder/api/__init__.py", 
line 1613, in get_list_headless
       response[API_RESULT_RES_KEY] = list_model_schema.dump(lst, many=True)
     File "/usr/local/lib/python3.10/site-packages/marshmallow/schema.py", line 
557, in dump
       result = self._serialize(processed_obj, many=many)
     File "/usr/local/lib/python3.10/site-packages/marshmallow/schema.py", line 
519, in _serialize
       return [
     File "/usr/local/lib/python3.10/site-packages/marshmallow/schema.py", line 
520, in <listcomp>
       self._serialize(d, many=False)
     File "/usr/local/lib/python3.10/site-packages/marshmallow/schema.py", line 
525, in _serialize
       value = field_obj.serialize(attr_name, obj, accessor=self.get_attribute)
     File "/usr/local/lib/python3.10/site-packages/marshmallow/fields.py", line 
344, in serialize
       return self._serialize(value, attr, obj, **kwargs)
     File "/usr/local/lib/python3.10/site-packages/marshmallow/fields.py", line 
1991, in _serialize
       return self._serialize_method(obj)
     File "/app/superset/queries/schemas.py", line 76, in get_sql_tables
       return obj.sql_tables
     File "/app/superset/models/sql_lab.py", line 75, in sql_tables
       extract_tables_from_jinja_sql(
     File "/app/superset/sql_parse.py", line 1110, in 
extract_tables_from_jinja_sql
       | ParsedQuery(
     File "/app/superset/sql_parse.py", line 280, in __init__
       self._parsed = sqlparse.parse(self.stripped())
     File "/app/superset/sql_parse.py", line 517, in stripped
       return self.sql.strip(" \t\r\n;")
   AttributeError: 'Template' object has no attribute 'strip'
   ```
   
   
   ### Checklist
   
   - [X] I have searched Superset docs and Slack and didn't find a solution to 
my problem.
   - [X] I have searched the GitHub issue tracker and didn't find a similar bug 
report.
   - [X] I have checked Superset's logs for errors and if I found a relevant 
Python stacktrace, I included it here as text in the "additional context" 
section.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to