This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new ce559e40efc Store callback and backfill enum values, not their repr,
in the DB (#76927)
ce559e40efc is described below
commit ce559e40efc418445c6a3af081491a7b6aa817d1
Author: Stephen Tyndall <[email protected]>
AuthorDate: Sun Nov 15 03:36:23 2026 -0500
Store callback and backfill enum values, not their repr, in the DB (#76927)
mysqlclient 2.3.1 binds str-subclass Enums through str(), so members
without __str__ were written as e.g. 'CallbackType.TRIGGERER'. On MySQL
this truncated callback.type to 'CallbackType.TRIGGER' and crash-looped
the scheduler. Give CallbackType, CallbackFetchMethod, ReprocessBehavior
and BackfillDagRunExceptionReason a __str__ returning their value, like
CallbackState and the other state enums already do.
closes: #76926
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
airflow-core/src/airflow/executors/workloads/callback.py | 3 +++
airflow-core/src/airflow/models/backfill.py | 6 ++++++
airflow-core/src/airflow/models/callback.py | 3 +++
airflow-core/tests/unit/models/test_backfill.py | 6 ++++++
airflow-core/tests/unit/models/test_callback.py | 7 +++++++
5 files changed, 25 insertions(+)
diff --git a/airflow-core/src/airflow/executors/workloads/callback.py
b/airflow-core/src/airflow/executors/workloads/callback.py
index 80b0fad2cf5..16970aa3b29 100644
--- a/airflow-core/src/airflow/executors/workloads/callback.py
+++ b/airflow-core/src/airflow/executors/workloads/callback.py
@@ -46,6 +46,9 @@ class CallbackFetchMethod(str, Enum):
# For deadline callbacks since they import callbacks through the import
path
IMPORT_PATH = "import_path"
+ def __str__(self) -> str:
+ return self.value
+
# Key in ``CallbackDTO.data`` naming how ``data["kwargs"]`` is encoded.
Without it the kwargs are
# passed to the callback as they are, as for callbacks stored before the key
was introduced.
diff --git a/airflow-core/src/airflow/models/backfill.py
b/airflow-core/src/airflow/models/backfill.py
index df54344c751..e25b18866d2 100644
--- a/airflow-core/src/airflow/models/backfill.py
+++ b/airflow-core/src/airflow/models/backfill.py
@@ -167,6 +167,9 @@ class ReprocessBehavior(str, Enum):
COMPLETED = "completed"
NONE = "none"
+ def __str__(self) -> str:
+ return self.value
+
class Backfill(Base):
"""Model representing a backfill job."""
@@ -253,6 +256,9 @@ class BackfillDagRunExceptionReason(str, Enum):
ALREADY_EXISTS = "already exists"
UNKNOWN = "unknown"
+ def __str__(self) -> str:
+ return self.value
+
class BackfillDagRun(Base):
"""Mapping table between backfill run and Dag run."""
diff --git a/airflow-core/src/airflow/models/callback.py
b/airflow-core/src/airflow/models/callback.py
index a1a0fe10997..eb8be732046 100644
--- a/airflow-core/src/airflow/models/callback.py
+++ b/airflow-core/src/airflow/models/callback.py
@@ -91,6 +91,9 @@ class CallbackType(str, Enum):
EXECUTOR = "executor"
DAG_PROCESSOR = "dag_processor"
+ def __str__(self) -> str:
+ return self.value
+
class CallbackDefinitionProtocol(Protocol):
"""Protocol for TaskSDK Callback definition."""
diff --git a/airflow-core/tests/unit/models/test_backfill.py
b/airflow-core/tests/unit/models/test_backfill.py
index 235b462e882..70cc5ca79f7 100644
--- a/airflow-core/tests/unit/models/test_backfill.py
+++ b/airflow-core/tests/unit/models/test_backfill.py
@@ -1648,3 +1648,9 @@ def
test_handle_clear_run_preserves_partition_key(dag_maker, session):
)
assert bdr is not None
assert bdr.partition_key == partition_key
+
+
[email protected]("member", [*ReprocessBehavior,
*BackfillDagRunExceptionReason])
+def test_enum_str_is_value(member):
+ # DB drivers may bind str-Enum members through str(); mysqlclient>=2.3.1
does.
+ assert str(member) == member.value
diff --git a/airflow-core/tests/unit/models/test_callback.py
b/airflow-core/tests/unit/models/test_callback.py
index f1e5f884add..7ed7aa03618 100644
--- a/airflow-core/tests/unit/models/test_callback.py
+++ b/airflow-core/tests/unit/models/test_callback.py
@@ -34,6 +34,7 @@ from airflow.models.callback import (
Callback,
CallbackFetchMethod,
CallbackState,
+ CallbackType,
DagProcessorCallback,
ExecutorCallback,
TriggererCallback,
@@ -615,3 +616,9 @@ class TestAcceptsContext:
def test_true_for_uninspectable_callable(self):
with patch("airflow._shared.module_loading.inspect.signature",
side_effect=ValueError):
assert accepts_context(lambda: None) is True
+
+
[email protected]("member", [*CallbackType, *CallbackFetchMethod])
+def test_enum_str_is_value(member):
+ # DB drivers may bind str-Enum members through str(); mysqlclient>=2.3.1
does.
+ assert str(member) == member.value