krsnik93 opened a new issue #13237:
URL: https://github.com/apache/superset/issues/13237


   Importing chart over API fails if the chart was built on top of a virtual 
dataset. I exported the chart with the `/chart/export` endpoint and then tried 
POSTing the resulting .zip to ` /chart/import`.
   
   ### Expected results
   
   Expect chart to get uploaded successfully.
   
   ### Actual results
   
   ```
   Feb 19 15:17:45 superset gunicorn[10599]:   File 
"/usr/local/lib/python3.8/site-packages/superset/models/slice.py", line 103, in 
cls_model
   Feb 19 15:17:45 superset gunicorn[10599]:     return 
ConnectorRegistry.sources[self.datasource_type]
   Feb 19 15:17:45 superset gunicorn[10599]: KeyError: 'view'
   Feb 19 15:17:45 superset gunicorn[10599]: During handling of the above 
exception, another exception occurred:
   Feb 19 15:17:45 superset gunicorn[10599]: Traceback (most recent call last):
   Feb 19 15:17:45 superset gunicorn[10599]:   File 
"/usr/local/lib/python3.8/site-packages/superset/charts/api.py", line 993, in 
import_
   Feb 19 15:17:45 superset gunicorn[10599]:     command.run()
   Feb 19 15:17:45 superset gunicorn[10599]:   File 
"/usr/local/lib/python3.8/site-packages/superset/charts/commands/importers/dispatcher.py",
 line 66, in run
   Feb 19 15:17:45 superset gunicorn[10599]:     raise exc
   Feb 19 15:17:45 superset gunicorn[10599]:   File 
"/usr/local/lib/python3.8/site-packages/superset/charts/commands/importers/dispatcher.py",
 line 55, in run
   Feb 19 15:17:45 superset gunicorn[10599]:     command.run()
   Feb 19 15:17:45 superset gunicorn[10599]:   File 
"/usr/local/lib/python3.8/site-packages/superset/commands/importers/v1/__init__.py",
 line 71, in run
   Feb 19 15:17:45 superset gunicorn[10599]:     raise self.import_error()
   Feb 19 15:17:45 superset gunicorn[10599]: 
superset.charts.commands.exceptions.ChartImportError: Import chart failed for 
an unknown reason
   ```
   
   #### How to reproduce the bug
   
   1. Create a virtual dataset in SQL Lab
   2. Create a chart on top of that dataset
   3. Export chart via REST API `/chart/export` endpoint with:
   `curl -v --cookie "session=<your_cookie>" --output <filename>.zip 
http://<your_host>/api/v1/chart/export/?q=[<your_chart_id>]`
   4. Try to import resulting .zip file with:
   `curl 'http://superset.ikrsnik.devonly.net/api/v1/chart/import/' \
        -X POST \
       -H 'Cookie: session=<your_cookie>'  \
       -H "X-CSRF-Token: <your_csrf_token>" \
       -F formData=@<filename>.zip \
       -F overwrite=true \
       --compressed \
       --insecure`
   
   ### Environment
   
   (please complete the following information):
   
   - superset version: 1.0.0
   - python version: 3.8.7
   - node.js version: v12.20.1
   
   ### Checklist
   
   Make sure to follow these steps before submitting your issue - thank you!
   
   - [x] I have checked the superset logs for python stacktraces and included 
it here as text if there are any.
   - [x] I have reproduced the issue with at least the latest released version 
of superset.
   - [x] I have checked the issue tracker for the same issue and I haven't 
found one similar.
   


----------------------------------------------------------------
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.

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