Uh oh!
There was an error while loading. Please reload this page.
Unify task/asset state storage between Core API and Execution API - #67547
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
amoghrajesh
commented
May 29, 2026
Thanks for reviews, merging this one |
Uh oh!
There was an error while loading. Please reload this page.
Backport failed to create: airflow-ctl/v0-1-test. View the failure log Run detailsNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
You can attempt to backport this manually by running: cherry_picker c1299bd airflow-ctl/v0-1-testThis should apply the commit to the airflow-ctl/v0-1-test branch and leave the commit in conflict state marking After you have resolved the conflicts, you can continue the backport process by running: cherry_picker --continueIf you don't have cherry-picker installed, see the installation guide. |
amoghrajesh
commented
May 29, 2026
No need to backport this |
Was generative AI tooling used to co-author this PR?
What problem are we solving?
Task and asset state written by workers (via the Execution API) is stored as JSON-encoded strings in the DB — e.g., the integer
42is stored as"42", and the string"hello"as'"hello"'. The core API read path returned the raw DB string without decoding it, so callers saw'"hello"'instead of"hello"and"42"(a string) instead of42(an integer).The write path had the inverse bug: values posted to the core API were stored without
json.dumps, so a worker reading them back via the execution API would hit aJSONDecodeError.Current behaviour
/dags/{dag_id}/dagRuns/{run_id}/taskInstances/{task_id}/statesand the equivalent asset state endpoints return raw JSON-encoded strings in the value field (e.g. ""hello"", "42" as a string).Classic example is if I run this task:
Core API call to get all task states returned this:
{ "task_states": [ { "key": "int_value", "value": "42", "updated_at": "2026-05-26T10:07:01.872139Z", "expires_at": "2026-06-25T10:07:01.868443Z" }, { "key": "job_id", "value": "\"12345\"", "updated_at": "2026-05-26T10:07:01.855922Z", "expires_at": "2026-06-25T10:07:01.851283Z" }, { "key": "secret-dict", "value": "{\"key\": \"value\"}", "updated_at": "2026-05-26T10:07:01.864312Z", "expires_at": "2026-06-25T10:07:01.860810Z" } ], "total_entries": 3 }Proposed change
value: strwidened tovalue: JsonValueon all four core API datamodels (TaskStateBody, TaskStateResponse, AssetStateBody, AssetStateResponse).json.dumps(body.value)before passing to the backend, matching the execution API as introduced in Simplifing authoring of task and asset states by allowing JSON types #67418json.loads(r.value)when constructing responses, so callers receive native types (int, dict, list, bool, str).null,non-finite floats (NaN, Inf, -Inf), and values whose serialized form exceeds 65535 bytes (preserving the old max_length constraint).NOTE: The UI PR: #67292 sends in raw values as entered by user, so no impact there.
Testing
Test 1: Set using task execution, Get using core API and task execution should have same response type
Test 2: Value set using core API, getting via task execution and core API should have same response type
Set values using curl for this task:
{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.