AIP-72: Add proper serialization for XCom and Variable responses#45104
Merged
kaxil merged 1 commit intoapache:mainfrom Dec 20, 2024
Merged
AIP-72: Add proper serialization for XCom and Variable responses#45104kaxil merged 1 commit intoapache:mainfrom
kaxil merged 1 commit intoapache:mainfrom
Conversation
kaxil
commented
Dec 20, 2024
amoghrajesh
approved these changes
Dec 20, 2024
Contributor
amoghrajesh
left a comment
There was a problem hiding this comment.
Looks good, one comment
0824e88 to
20f320d
Compare
This commit addresses serialization bug for XCom and Variable responses. Specifically: - Added `from_xcom_response` and `from_variable_response` class methods in XComResult and VariableResult, respectively, to convert autogenerated API responses into runtime-compatible result models. - Updated the supervisor’s `handle_requests` method to use these converters for `GetXCom` and `GetVariable` message handling. - Adjusted tests in test_supervisor.py to verify the inclusion of the type field in serialized responses and ensure proper decoding using CommsDecoder. - Improved test coverage by asserting that serialized responses match expected formats and verifying deserialization consistency.
20f320d to
8985b25
Compare
got686-yandex
pushed a commit
to got686-yandex/airflow
that referenced
this pull request
Jan 30, 2025
…che#45104) Currently Xcom & Variables fail on main with following error: ```py ValidationError: 1 validation error for tagged-union[StartupDetails,XComResult,ConnectionResult,VariableResult,ErrorResponse] Unable to extract tag using discriminator 'type' [type=union_tag_not_found, input_value={'key': 'test_key', 'value': 'test_value'}, input_type=dict] For further information visit https://errors.pydantic.dev/2.10/v/union_tag_not_found ``` The entire stacktrace is: ```py decoder.get_message() task_sdk/src/airflow/sdk/execution_time/task_runner.py:177: in get_message msg = self.decoder.validate_json(line) /usr/local/lib/python3.9/site-packages/pydantic/type_adapter.py:446: in validate_json return self.validator.validate_json( E pydantic_core._pydantic_core.ValidationError: 1 validation error for tagged-union[StartupDetails,XComResult,ConnectionResult,VariableResult,ErrorResponse] E Unable to extract tag using discriminator 'type' [type=union_tag_not_found, input_value={'key': 'test_key', 'value': 'test_value'}, input_type=dict] E For further information visit https://errors.pydantic.dev/2.10/v/union_tag_not_found ``` This commit addresses serialization bug for XCom and Variable responses. Specifically: - Added `from_xcom_response` and `from_variable_response` class methods in XComResult and VariableResult, respectively, to convert autogenerated API responses into runtime-compatible result models. - Updated the supervisor’s `handle_requests` method to use these converters for `GetXCom` and `GetVariable` message handling. - Adjusted tests in test_supervisor.py to verify the inclusion of the type field in serialized responses and ensure proper decoding using CommsDecoder. - Improved test coverage by asserting that serialized responses match expected formats and verifying deserialization consistency.
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.
Currently Xcom & Variables fail on main with following error:
The entire stacktrace is:
This commit addresses serialization bug for XCom and Variable responses. Specifically:
Added
from_xcom_responseandfrom_variable_responseclass methods in XComResult and VariableResult, respectively, to convert autogenerated API responses into runtime-compatible result models.Updated the supervisor’s
handle_requestsmethod to use these converters forGetXComandGetVariablemessage handling.Adjusted tests in test_supervisor.py to verify the inclusion of the type field in serialized responses and ensure proper decoding using CommsDecoder.
Improved test coverage by asserting that serialized responses match expected formats and verifying deserialization consistency.
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rstor{issue_number}.significant.rst, in newsfragments.