{"record":{"id":"79727ad265cf17c6","repo":"apache/superset","slug":"alert-query-must-be-read-only","errorCode":null,"errorMessage":"Alert query must be read-only","messagePattern":"Alert query must be read-only","errorType":"exception","errorClass":"AlertQueryError","httpStatus":400,"severity":"error","filePath":"superset/commands/report/alert.py","lineNumber":196,"sourceCode":"        )\n\n    def _get_alert_metadata_from_object(self) -> dict[str, Any]:\n        return {\n            \"report_schedule_id\": self._report_schedule.id,\n            \"execution_id\": self._execution_id,\n        }\n\n    def _validate_rendered_sql(self, rendered_sql: str) -> None:\n        \"\"\"\n        Enforce SQL-level constraints on the rendered alert query: a single\n        statement, and no mutations unless the database allows DML.\n        \"\"\"\n        database = self._report_schedule.database\n        script = SQLScript(rendered_sql, engine=database.backend)\n        if len(script.statements) != 1:\n            raise AlertQueryError(message=_(\"Alert query must be a single statement\"))\n        if script.has_mutation() and not database.allow_dml:\n            raise AlertQueryError(message=_(\"Alert query must be read-only\"))\n\n    @logs_context(context_func=_get_alert_metadata_from_object)\n    def _execute_query(self) -> pd.DataFrame:\n        \"\"\"\n        Executes the actual alert SQL query template\n\n        :return: A pandas dataframe\n        :raises AlertQueryError: SQL query is not valid\n        :raises AlertQueryTimeout: The SQL query received a celery soft timeout\n        \"\"\"\n        sql_template = jinja_context.get_template_processor(\n            database=self._report_schedule.database\n        )\n\n        try:\n            rendered_sql = sql_template.process_template(self._report_schedule.sql)\n            self._validate_rendered_sql(rendered_sql)\n            limited_rendered_sql = self._report_schedule.database.apply_limit_to_sql(","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/report/alert.py#L178-L214","documentation":"Error \"Alert query must be read-only\" thrown in apache/superset.","triggerScenarios":"The alert query attempts to mutate data, which alerts forbid.","commonSituations":"Configuring an alert with INSERT/UPDATE/DELETE or other mutating SQL; alerts must be read-only SELECT queries.","solutions":["Remove INSERT/UPDATE/DELETE and other mutating statements; use a read-only SELECT."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}