{"record":{"id":"32fcc8340e5e69a2","repo":"apache/superset","slug":"error-error-s","errorCode":null,"errorMessage":"Error: %(error)s","messagePattern":"Error: (.+?)","errorType":"exception","errorClass":"ChartDataQueryFailedError","httpStatus":400,"severity":"error","filePath":"superset/commands/chart/data/get_data_command.py","lineNumber":60,"sourceCode":"        # caching is handled in query_context.get_df_payload\n        # (also evals `force` property)\n        cache_query_context = kwargs.get(\"cache\", False)\n        force_cached = kwargs.get(\"force_cached\", False)\n        try:\n            payload = self._query_context.get_payload(\n                cache_query_context=cache_query_context, force_cached=force_cached\n            )\n        except CacheLoadError as ex:\n            raise ChartDataCacheLoadError(ex.message) from ex\n\n        # Skip error check for query-only requests - errors are returned in payload\n        # This allows View Query modal to display validation errors\n        for query in payload[\"queries\"]:\n            if (\n                query.get(\"error\")\n                and self._query_context.result_type != ChartDataResultType.QUERY\n            ):\n                raise ChartDataQueryFailedError(\n                    _(\"Error: %(error)s\", error=query[\"error\"])\n                )\n\n        return_value = {\n            \"query_context\": self._query_context,\n            \"queries\": payload[\"queries\"],\n        }\n        if cache_query_context:\n            return_value.update(cache_key=payload[\"cache_key\"])\n\n        return return_value\n\n    def execute(self, **kwargs: Any) -> ChartDataExecutionResult:\n        \"\"\"Execute and return timing as a typed sidecar.\"\"\"\n        cache_query_context = kwargs.get(\"cache\", False)\n        force_cached = kwargs.get(\"force_cached\", False)\n        try:\n            result = self._query_context.get_payload_result(","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/chart/data/get_data_command.py#L42-L78","documentation":"ChartDataQueryFailedError raised in ChartDataCommand.run() (get_data_command.py:60) when any query payload carries an 'error' entry after execution. get_payload() collects per-query exceptions (SQL errors, engine failures, timeout) into payload['queries'][i]['error'] instead of raising; this loop converts them to a command exception with the message interpolated into 'Error: %(error)s'. Skipped when result_type is QUERY (View Query modal wants the error in-band).","triggerScenarios":"POST /api/v1/chart/data where the underlying database rejects the SQL (syntax error, unknown column, missing table), the query times out, or the engine driver raises; any result type other than 'query' (e.g. results, samples) triggers the raise.","commonSituations":"Chart referencing a column dropped from the dataset; DB connection expired/invalid; query timeouts on large tables; wrong SQL clause in custom SQL metrics.","solutions":["Read the interpolated database error text — it names the real cause (column, table, timeout).","Open the chart in Explore and run 'View Query' (result_type=query) to get the in-band error plus generated SQL for debugging.","Fix the dataset/chart definition (re-add missing column, adjust time grain/metric) or the underlying table, then re-run.","For timeouts, raise SQLLAB_QUERY_TIME_LIMIT or optimize the query."],"exampleFix":"# before\nresult = ChartDataCommand(qc).run()  # raises ChartDataQueryFailedError('Error: column X not found')\n\n# after\nqc.result_type = ChartDataResultType.QUERY\nresult = ChartDataCommand(qc).run()  # error returned in-band; inspect result['queries'][0]['error'] and ['query']","handlingStrategy":"try-catch","validationCode":"# cheap pre-flight: confirm the dataset/table still resolves\nfrom superset.utils.core import get_datasource_by_id\n\nds = get_datasource_by_id(query_context.datasource.id, query_context.datasource.type)\nif ds is None:\n    return {\"error\": \"datasource missing; refresh chart dataset\"}, 400","typeGuard":null,"tryCatchPattern":"try:\n    result = ChartDataCommand(qc).run()\nexcept ChartDataQueryFailedError as ex:\n    db_error = str(ex).removeprefix(\"Error: \")\n    log.warning(\"query failed: %s\", db_error)\n    return {\"error\": db_error}, 500","preventionTips":["Use result_type=QUERY ('View Query') during debugging to get the in-band error and SQL.","Keep dataset schemas in sync with the source DB (re-sync columns after schema changes).","Set realistic SQLLAB_QUERY_TIME_LIMIT and index tables for dashboard query patterns."],"tags":["chart-data","sql","query-failure","database"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}