Repository navigation
Fix 500 error for event logs with NULL dttm - #68338
Merged
Merged
Conversation
Logs with dttm=NULL cause a Pydantic validation error (500) because
EventLogResponse.dttm is non-optional. Filter them out at the query
level: GET /eventLogs/{id} returns 404, GET /eventLogs excludes them
from results and total_entries.
closes: apache#68333
Vasu-Madaan
requested review from
bugraoz93,
choo121600,
ephraimbuddy,
jason810496,
pierrejeambrun,
rawwar and
shubhamraj-git
as code owners
June 10, 2026 13:06
Member
|
This is sort of just papering over the crack. The DB table should be changed to not allow nullable value since everything else in Airflow expects it to not be null. But such a migration needs to be done with care, as the |
ashb
reviewed
Jun 10, 2026
pierrejeambrun
left a comment
Member
There was a problem hiding this comment.
Nice short term workaround.
+1 for adding comments there as to why this is filtered out, and why changing the 'response' model isn't a good idea.
pierrejeambrun
approved these changes
Jun 10, 2026
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.
Summary
Log.dttmis nullable at the database level, butEventLogResponse.dttm(whenin the API) is declared as a non-optionaldatetime. When a log row hasdttm=NULL, FastAPI/Pydantic raises a validation error producing a 500 Internal Server Error instead of a sensible response.This happens for legacy records or rows inserted directly into the database bypassing the model (which always sets
dttm = timezone.utcnow()in__init__).Why this approach
Rather than making
whennullable in the API schema (a breaking contract change that would affect all API consumers expecting a non-null timestamp), we filter out null-dttm rows at the query level:GET /eventLogs/{id}— returns 404 for a log whosedttmisNULL. The resource is not serveable through this API.GET /eventLogs— silently excludes null-dttm rows from both the results andtotal_entries, keeping the response consistent and well-typed.This is the minimal, safe fix: it stops the 500 crash without changing the API contract or requiring a schema migration.
closes: #68333
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (claude-sonnet-4-6) following the guidelines