eschutho opened a new pull request, #45819:
URL: https://github.com/apache/superset/pull/45819

   ### SUMMARY
   **Root cause:** In `_execute_task_body` (`superset/tasks/scheduler.py`), the 
generic `except Exception` branch logged every task failure with 
`logger.error(..., exc_info=True)`. A user-fixable, client-class error such as 
`QueryObjectValidationError` (status 400, and its subclass 
`SemanticResultCompletenessError`), deliberately raised by 
`execute_chart_query` when a chart query is invalid (e.g. a Time Comparison 
without an enclosed time range, missing columns, empty query), was therefore 
logged as an ERROR with a traceback, indistinguishable from a server fault. 
This is the follow-up anticipated in the discussion on #43464.
   
   **Fix:** In that branch only, if the exception has an int `status` in `[400, 
500)` (as `SupersetException` subclasses do), log at WARNING without a 
traceback. All other exceptions keep ERROR + `exc_info=True`. The log message 
keeps the task type, uuid and error text. I used a small explicit check rather 
than `get_logger_from_status`, since that helper maps 5xx to `logger.exception` 
and requires an int status for every exception, which generic exceptions lack.
   
   The FAILURE transition, `ctx.error_properties`, and the `gtf.task.failure` 
counter are untouched. `execute_chart_query` re-raises the same exception 
object and nothing between it and this handler wraps it (it runs directly under 
`use_context`), so this is the live path.
   
   ### TRADEOFFS
   Client-class task failures now log at WARNING instead of ERROR, so they no 
longer produce error-level log events or alerts. The task still ends in FAILURE 
with the same client-facing `error_message`, and `gtf.task.failure` is still 
incremented. Operators who relied on ERROR logs to notice these failures will 
need to look at WARNING logs or the counter. A genuine bug that surfaces as a 
4xx `SupersetException` would also be logged at WARNING; 5xx and non-Superset 
exceptions are unaffected.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   N/A
   
   ### TESTING INSTRUCTIONS
   `pytest tests/unit_tests/tasks/` (692 passed). New tests in 
`tests/unit_tests/tasks/test_scheduler_executor.py`:
   - `QueryObjectValidationError` and `SemanticResultCompletenessError` -> task 
transitions to FAILURE with the same error message, `gtf.task.failure` 
incremented, a single WARNING record with no `exc_info`, and no ERROR record.
   - `RuntimeError` and a `SupersetException` with status 500 -> still logged 
at ERROR with `exc_info`.
   
   `ruff check` and `ruff format` are clean.
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


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

To unsubscribe, e-mail: [email protected]

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