Skip to content

Fix serialization of datetimes with a fixed UTC offset - #74922

Open
justinpakzad wants to merge 1 commit into
apache:mainfrom
justinpakzad:fix/datetime-serialization-fixed-offset
Open

justinpakzad wants to merge 1 commit into
apache:mainfrom
justinpakzad:fix/datetime-serialization-fixed-offset

Conversation

@justinpakzad

@justinpakzad justinpakzad commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

The serde timezone serializer can't handle timezones that are just a fixed offset with no name. The datetime serializer saves an empty place holder and reading the value back (e.g., via Xcom pull) fails. Take the following Dag:

from datetime import datetime
from airflow.sdk import dag, task

@dag
def serde_offset_tz():
    @task
    def push_offset():
        return datetime.fromisoformat("2024-01-01T00:00:00+02:00")
    @task
    def do_something(value):
        print(repr(value), value.utcoffset())

    do_something(push_offset())
serde_offset_tz()

On main, do_something would fail with: ValueError: ZoneInfo keys must be normalized relative paths, got:

This PR adds support for timezones with a fixed, nonzero UTC offset and no name, by encoding them as a pendulum FixedTimezone. Additional tests were added to cover the new behavior. The NoNameTZ helper now returns None from utcoffset so that test_timezone_serialize_no_name still covers the fallback path (no name or fixed offset).

Was generative AI tooling used to co-author this PR?
  • Yes (Claude Sonnet 5.5)

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@justinpakzad
justinpakzad force-pushed the fix/datetime-serialization-fixed-offset branch from 2a28470 to b22fb93 Compare October 18, 2026 00:39
@justinpakzad
justinpakzad marked this pull request as ready for review October 18, 2026 00:40

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant