Fix 500 Error in FAB API Users endpoint by allowing naive datetimes i…#62327
Merged
vincbeck merged 3 commits intoapache:mainfrom Feb 23, 2026
Merged
Fix 500 Error in FAB API Users endpoint by allowing naive datetimes i…#62327vincbeck merged 3 commits intoapache:mainfrom
vincbeck merged 3 commits intoapache:mainfrom
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
|
henry3260
reviewed
Feb 22, 2026
providers/fab/src/airflow/providers/fab/auth_manager/api_fastapi/datamodels/users.py
Outdated
Show resolved
Hide resolved
vincbeck
approved these changes
Feb 23, 2026
Contributor
vincbeck
left a comment
There was a problem hiding this comment.
Looks good, let's see the CI
henry3260
approved these changes
Feb 23, 2026
Contributor
|
Since CI is passing, we don't really need to merge it manually. |
|
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
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.
Description
This PR resolves a 500 Internal Server Error that occurs when hitting the FastAPI
GET /auth/fab/v1/usersendpoint on a live database (e.g., MySQL or Postgres).The Issue:
The new Pydantic UserResponse datamodel was overly strict, enforcing [UtcDateTime] for the
last_login,created_on, andchanged_onfields.Because the FAB provider inherits its SQLAlchemy models directly from
Flask-AppBuilderfor legacy compatibility, the [ab_user] database schema defines these fields using standard naivesqlalchemy.DateTime.When SQLAlchemy retrieves these rows from MySQL/Postgres, it returns naive
datetime.datetimeobjects. Pydantic immediately rejects these naive datetimes, crashing the API.Why this bypassed CI:
The existing unit tests for the
/usersroutes used Python mocks where these timestamp fields were completely omitted (Noneis permitted by the schema), meaning the strictUtcDateTimevalidation logic was never tested against standard naive SQLAlchemy database objects.The Fix:
UtcDateTimeto strictdatetime.datetimeinside theUserResponseschema (providers/fab/src/airflow/providers/fab/auth_manager/api_fastapi/datamodels/users.py) so it properly aligns with the actual SQLAlchemyUsermodel output.providers/fab/tests/unit/fab/auth_manager/api_fastapi/datamodels/test_users.pyto ensure naive datetimes are correctly preserved rather than strictly coerced or rejected.Testing/Verification
Related Issues
Fixes: #62325