myheartsgoon commented on issue #15692:
URL: https://github.com/apache/superset/issues/15692#issuecomment-881862635


   I also encounter the same problem when using latest 1.2.0. 
   Below is my setting: 
   
![image](https://user-images.githubusercontent.com/24839228/126030862-b408c785-38c4-4abf-8e47-45d744ec61fa.png)
   
   Below is the error in the superset logs when opening the "Upload CSV" page:
   
   
![image](https://user-images.githubusercontent.com/24839228/126031264-e4e3d166-4017-4f96-883f-6aa66e071647.png)
   
   
   
   I checked the put request that sent to the backend for enabling csv upload: 
`https://{superset_url}/api/v1/database/13`
   In the request payload, the parameter "schemas_allowed_for_csv_upload" in 
`extra` was incorrectly set. It will cause `schemas_allowed_for_csv_upload` 
gets json parsed into string type instead of list type (source code in 
`superset.models.core.Database.get_schema_access_for_csv_upload` function). 
   
   
   `extra` in the request payload in my case:
   
`"{\"metadata_params\":{},\"engine_params\":{},\"schemas_allowed_for_csv_upload\":\"[\\\"superset_upload\\\"]\"}"`
   
   and after json parsing :
   
   `>>> 
json.loads("{\"metadata_params\":{},\"engine_params\":{},\"schemas_allowed_for_csv_upload\":\"[\\\"superset_upload\\\"]\"}")
   {'metadata_params': {}, 'engine_params': {}, 
'schemas_allowed_for_csv_upload': '["superset_upload"]'}`
   
   You can see `schemas_allowed_for_csv_upload` became a string instead of 
list. And it will raise the error `TypeError: can only concatenate str (not 
"list") to str`
   
   
![image](https://user-images.githubusercontent.com/24839228/126027778-912a8ffb-3dc9-4f8c-9dbd-4dca7d3870ec.png)
   
   ```python 
       def get_schema_access_for_csv_upload(  # pylint: disable=invalid-name
           self,
       ) -> List[str]:
           allowed_databases = 
self.get_extra().get("schemas_allowed_for_csv_upload", [])
           if hasattr(g, "user"):
               extra_allowed_databases = config["ALLOWED_USER_CSV_SCHEMA_FUNC"](
                   self, g.user
               )
               allowed_databases += extra_allowed_databases
           return sorted(set(allowed_databases))
   ```


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to