Skip to content

Fix task state store custom expiry datetime missing timezone on save#68823

Merged
pierrejeambrun merged 1 commit into
apache:mainfrom
astronomer:aip-103-ui-bug-beta
Jun 22, 2026
Merged

Fix task state store custom expiry datetime missing timezone on save#68823
pierrejeambrun merged 1 commit into
apache:mainfrom
astronomer:aip-103-ui-bug-beta

Conversation

@amoghrajesh

Copy link
Copy Markdown
Contributor

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

closes: #68747

What

Saving a task state store entry with a custom expiry date fails with a 422. The datetime-local input returns a bare YYYY-MM-DDTHH:mm string, but the API requires a timezone-aware datetime.

Error was:

{
    "detail": [
        {
            "type": "timezone_aware",
            "loc": [
                "body",
                "expires_at",
                "datetime"
            ],
            "msg": "Input should have timezone info",
            "input": "2026-07-22T10:25"
        },
        {
            "type": "literal_error",
            "loc": [
                "body",
                "expires_at",
                "literal['default']"
            ],
            "msg": "Input should be 'default'",
            "input": "2026-07-22T10:25",
            "ctx": {
                "expected": "'default'"
            }
        }
    ]
}

Current behaviour

Editing an existing entry auto-selects "Custom" expiry (the API always returns a resolved absolute datetime). Clicking Save sends "2026-07-22T10:25" and the API rejects it with Input should have timezone info.

Proposed change

Convert the picker value to a timezone-aware ISO string via dayjs.tz(customExpiresAt, selectedTimezone).toISOString() before sending. Extracted into a getExpiresAt() helper to replace the nested ternary in onSave. Applies to both add and edit flows.

Same flow works fine now:
image

curl 'http://localhost:28080/api/v2/dags/example_task_state_store/dagRuns/manual__2026-06-22T05%3A13%3A57.081200%2B00%3A00/taskInstances/run_job/state-store/abcd?map_index=-1' \
  -X 'PUT' \
  -H 'Accept: application/json' \
  -H 'Accept-Language: en-GB,en;q=0.9' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  --data-raw '{"expires_at":"2026-07-22T05:14:00.000Z","value":1000}'

  • 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.

@guan404ming guan404ming left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@amoghrajesh amoghrajesh added the backport-to-v3-3-test Backport to v3-3-test label Jun 22, 2026
@pierrejeambrun pierrejeambrun merged commit b9cc222 into apache:main Jun 22, 2026
85 checks passed
@pierrejeambrun pierrejeambrun deleted the aip-103-ui-bug-beta branch June 22, 2026 11:27
@github-actions

Copy link
Copy Markdown
Contributor

Backport successfully created: v3-3-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
v3-3-test PR Link

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

Labels

area:UI Related to UI/UX. For Frontend Developers. backport-to-v3-3-test Backport to v3-3-test

Projects

Development

Successfully merging this pull request may close these issues.

Editing task state store throws validation error

3 participants