apache / apache/superset

Unable to get chart data through this API: api/v1/chart/{pk}/data/

Open
#33,615 9 comments 0 reactions 0 assignees View on GitHub
api api:charts validation:required
Dominant language
Python
Stars
74.8k
Forks
18.3k
Avg merge
2d 4h
Merged PRs (30d)
664

Description

### Bug description

We are trying to fetch chart data using /api/v1/chart/2910/data API, but we are getting 400 response with message "Chart has no query context saved. Please save the chart again".
WorkAround: When we try hitting this API after manually opening the chart again, the API is able to fetch data. (We have around 100 charts because of which this workaround is not a feasible option for us)

P.S. We are using zip file to import dashboards

### Screenshots/recordings

![Image](https://github.com/user-attachments/assets/1dd08cf9-7865-4cfb-8bf4-24794fd9584e)
Query Context is null, when hitting API: http://localhost:8088/api/v1/chart/2030

![Image](https://github.com/user-attachments/assets/abe53068-1225-43f8-8b77-54faa73776be)
Message after hitting API: http://localhost:8088/api/v1/chart/2030/data/

**After Opening the Chart**
Query Context is populated

Data is coming after this.

### Superset version

4.0.2

### Python version

3.9

### Node version

16

### Browser

Chrome

### Additional context

_No response_

### 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.
- [ ] 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.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the import and request flow described for /api/v1/chart/{pk} and /api/v1/chart/{pk}/data/, comparing a ZIP-imported chart with one opened and saved manually. Trace where the chart's query context is populated and where the data endpoint rejects a missing context. Done means imported charts can return data without being opened manually, with regression coverage for that path.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend, data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.