[v3-3-test] Make deadline reads and serialization robust to dynamic/malformed intervals (#68919) - #70625
Draft
github-actions[bot] wants to merge 1 commit into
Draft
[v3-3-test] Make deadline reads and serialization robust to dynamic/malformed intervals (#68919)#70625github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
…alformed intervals (#68919) * Make deadline reads and serialization robust to dynamic/malformed intervals Hardens the read and (de)serialization paths for deadline alerts so dynamic (``VariableInterval``) and malformed stored data no longer break the UI/API. - UI deadline-alert response: ``DeadlineAlert.interval`` is a JSON column holding the Airflow-serialized interval, not a plain number. Coerce it to seconds for a fixed ``timedelta`` and to ``None`` for a dynamic ``VariableInterval`` (resolved later by the scheduler), instead of letting Pydantic 500 on the dict. The ``interval`` field becomes ``float | None``. - Drop ``interval`` from the sortable columns of the deadline-alerts endpoint: ordering by a JSON column sorts by structure/text, not duration, so the result was arbitrary and misleading. - Deserialization: route by the encoder-stamped ``__class_path`` ahead of the ``reference_type`` name (a custom reference may share a class name with a builtin), and raise a clear error for a reference with no importable ``__class_path`` instead of an opaque ``KeyError``. - ``Deadline.__repr__`` / ``DeadlineAlert.__repr__`` no longer raise: guard the ``dagrun`` relationship (the FK can be set while the relationship is None after a cascade delete) and handle the dict-shaped JSON interval. A ``__repr__`` must never raise. - ``prune_deadlines`` explicitly excludes deadlines already marked ``missed`` so a missed deadline (whose callback is owned by the scheduler/triggerer) and its queued callback are never cascade-deleted. Generated-by: Claude Code (Opus via Claude Code) on behalf of Sean Ghaeli * Remove redundant comments in deadline sort/deserialize The sort-key comment restated a constraint already covered by test_order_by_interval_is_rejected; the __class_path comment restated the ValueError message right below it. Generated-by: Claude Code (Opus) * Trim PR to the UI deadlineAlerts 500 fix only Per review: keep only the interval coercion, order_by removal, and their tests; move repr guards, decoder routing, and prune guard to a follow-up. --------- (cherry picked from commit f840a82) Co-authored-by: Sean Ghaeli <58916776+seanghaeli@users.noreply.github.com> Co-authored-by: Sean Ghaeli <ghaeli@amazon.com>
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hardens the read and (de)serialization paths for deadline alerts so dynamic
(
VariableInterval) and malformed stored data no longer break the UI/API.DeadlineAlert.intervalis a JSON column holdingthe Airflow-serialized interval, not a plain number. Coerce it to seconds for a
fixed
timedeltaand toNonefor a dynamicVariableInterval(resolvedlater by the scheduler), instead of letting Pydantic 500 on the dict. The
intervalfield becomesfloat | None.intervalfrom the sortable columns of the deadline-alerts endpoint:ordering by a JSON column sorts by structure/text, not duration, so the result
was arbitrary and misleading.
__class_pathahead of thereference_typename (a custom reference may share a class name with abuiltin), and raise a clear error for a reference with no importable
__class_pathinstead of an opaqueKeyError.Deadline.__repr__/DeadlineAlert.__repr__no longer raise: guard thedagrunrelationship (the FK can be set while the relationship is None after acascade delete) and handle the dict-shaped JSON interval. A
__repr__mustnever raise.
prune_deadlinesexplicitly excludes deadlines already markedmissedso amissed deadline (whose callback is owned by the scheduler/triggerer) and its
queued callback are never cascade-deleted.
Generated-by: Claude Code (Opus via Claude Code) on behalf of Sean Ghaeli
The sort-key comment restated a constraint already covered by
test_order_by_interval_is_rejected; the __class_path comment restated the
ValueError message right below it.
Generated-by: Claude Code (Opus)
Per review: keep only the interval coercion, order_by removal, and their
tests; move repr guards, decoder routing, and prune guard to a follow-up.
(cherry picked from commit f840a82)
Co-authored-by: Sean Ghaeli 58916776+seanghaeli@users.noreply.github.com
Co-authored-by: Sean Ghaeli ghaeli@amazon.com