GokulArumugam opened a new pull request, #77516:
URL: https://github.com/apache/airflow/pull/77516

   Follow-up to #76927 and #77418.
   
   `mysqlclient 2.3.1` binds `str`-subclass `Enum` query parameters through 
`str()`. On Python 3.11+, `(str, Enum)` classes without `__str__` evaluate to 
`EnumName.MEMBER` instead of their string value. Four model enums in 
`airflow-core/src/airflow/models/` were still `(str, Enum)` without `__str__`:
   
   - `DagWarningType` (`airflow/models/dagwarning.py`)
   - `TriggerKind`, `TriggerStatus`, `TriggerFailureReason` 
(`airflow/models/trigger.py`)
   
   ### Impact on MySQL (`mysqlclient 2.3.1`)
   Reproduced locally against MySQL 8.4.13 with `mysqlclient==2.3.1`:
   1. `SchedulerJobRunner._activate_referenced_assets()` binds 
`'DagWarningType.ASSET_CONFLICT'` in its lookup and delete queries against 
stored `'asset conflict'` rows, causing a PK `IntegrityError` (`Duplicate entry 
'...-asset conflict' for key 'dag_warning.PRIMARY'`) on the next pass and 
preventing resolved conflict warnings from being deleted.
   2. `_update_dag_warnings()` passes `DagWarningType` members directly into 
`DagWarning.warning_type.in_(warning_types)`, leaving resolved DAG warnings 
orphaned.
   3. `GET /api/v2/dagWarnings?warning_type=...` and `GET 
/api/v2/triggers?kind=...` pass `DagWarningType` / `TriggerKind` through 
`FilterParam.to_orm()`, returning 0 rows instead of matching rows.
   
   ### Changes
   - Convert `DagWarningType`, `TriggerKind`, `TriggerStatus`, and 
`TriggerFailureReason` to `StrEnum`.
   - Add parametrized `test_enum_str_is_value` unit tests in 
`test_dagwarning.py` and `test_trigger.py` (matching #76927).
   
   ### Verification
   - Re-ran all 5 MySQL 8.4.13 + `mysqlclient==2.3.1` scenarios after the fix 
(all pass).
   - Ran `pytest` on `test_dagwarning.py` and `test_trigger.py` (126 passed), 
`mypy`, and `ruff`.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (used AI assistance to help identify and verify the issue)
   


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

  • [PR] Use StrEnum for DagWarnin... GokulArumugam (via GitHub) via commits

Reply via email to