How to retrieve chart rendering errors through Superset Python API? #31484
Replies: 1 comment
-
Hey @birajsilwal! I'm here to help you with any bugs, questions, or contributions. Let's work together to solve this issue! The issue you're encountering, where you receive a 200 status code even when there are errors in the chart, might be related to how Superset handles error reporting in its API responses. The Superset API typically returns a 200 status code for successful requests, even if the response contains error information within the data payload. To capture error messages from the Superset API, you should look for error details within the response data itself, rather than relying solely on the HTTP status code. The error messages are usually located in the Here's how you can modify your script to check for errors within the response data: def get_chart_data_and_logs(session, chart_id):
logging.info(f'Getting chart data and logs for chart ID: {chart_id}')
try:
response = session.get(f"{SUPERSET_URL}/chart/{chart_id}/data")
response.raise_for_status()
data = response.json()
# Check for errors in the response data
if 'queries' in data:
for query in data['queries']:
if 'error' in query and query['error']:
logging.error(f"Chart error: {query['error']}")
return response.status_code, query['error']
logging.info(f"Successfully retrieved chart data")
return response.status_code, data
except requests.RequestException as e:
if hasattr(e, 'response') and e.response is not None and 500 <= e.response.status_code < 600:
logging.error(f"Server error: {e.response.status_code}")
logging.error(f"Response content: {e.response.text}")
raise Exception(f"Server error occurred: {str(e)}")
elif not hasattr(e, 'response') or e.response is None:
logging.error(f"Network or connection error: {str(e)}")
raise Exception(f"Connection error: {str(e)}")
else:
logging.error(f"Unexpected error: {str(e)}")
raise Exception(f"Unexpected error occurred: {str(e)}") This modification checks for the presence of an To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Beta Was this translation helpful? Give feedback.
-
When clicking on a chart in the Superset UI, I receive an error message: "Unexpected error: Datetime column not provided as part table configuration and is required by this type of chart." shown in the screenshot below)
My goal is to capture this error message through the Python API. While I'm not specifically focused on this particular message, I want to be able to retrieve any unexpected chart errors using the API.
However, I consistently receive a 200 status code even when the chart contains errors. Initially, with the same script and chart ID, I successfully received the exact error message shown in the UI for the first few attempts. But after those initial tries, it keeps returning 200.
I've tried:
Here is the python script.
Here's the current output:
Beta Was this translation helpful? Give feedback.
All reactions