Apply reserved-key check to XCom update payload#65915
Conversation
6ac254a to
e23a515
Compare
XComCreateBody (POST /xcomEntries) rejects payloads containing
reserved serialization keys (__classname__, __type, __var,
__data__, …) via a field_validator that walks the value
recursively. XComUpdateBody (PATCH /xcomEntries/{key}) was
missing the same validator, so a payload that POST correctly
rejects with 422 was accepted on PATCH and stored as-is.
Extracts the recursive walker to a module-level
_check_forbidden_xcom_keys helper and has both XComCreateBody
and XComUpdateBody delegate to it, so create and update apply
the same payload-key check from a single source. A parametrized
test mirroring the existing
test_create_xcom_entry_blocks_forbidden_keys covers the PATCH
path.
e23a515 to
cdf529d
Compare
|
Chance for a review :) |
|
Hi maintainer, this PR was merged without a milestone set.
|
Backport failed to create: v3-2-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 c173489 v3-2-testThis should apply the commit to the v3-2-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. |
XComCreateBody (POST /xcomEntries) rejects payloads containing
reserved serialization keys (__classname__, __type, __var,
__data__, …) via a field_validator that walks the value
recursively. XComUpdateBody (PATCH /xcomEntries/{key}) was
missing the same validator, so a payload that POST correctly
rejects with 422 was accepted on PATCH and stored as-is.
Extracts the recursive walker to a module-level
_check_forbidden_xcom_keys helper and has both XComCreateBody
and XComUpdateBody delegate to it, so create and update apply
the same payload-key check from a single source. A parametrized
test mirroring the existing
test_create_xcom_entry_blocks_forbidden_keys covers the PATCH
path.
XComCreateBody (POST /xcomEntries) rejects payloads containing
reserved serialization keys (__classname__, __type, __var,
__data__, …) via a field_validator that walks the value
recursively. XComUpdateBody (PATCH /xcomEntries/{key}) was
missing the same validator, so a payload that POST correctly
rejects with 422 was accepted on PATCH and stored as-is.
Extracts the recursive walker to a module-level
_check_forbidden_xcom_keys helper and has both XComCreateBody
and XComUpdateBody delegate to it, so create and update apply
the same payload-key check from a single source. A parametrized
test mirroring the existing
test_create_xcom_entry_blocks_forbidden_keys covers the PATCH
path.
(cherry picked from commit c173489)
XComCreateBody(POST/xcomEntries) rejects payloads containing reservedserialization keys (
__classname__,__type,__var,__data__, …) via afield_validatorthat walks the value recursively.XComUpdateBody(PATCH/xcomEntries/{key}) was missing the same validator, so a payload that POSTcorrectly rejects with 422 was accepted on PATCH and stored as-is.
This change extracts the recursive walker to a module-level
_check_forbidden_xcom_keyshelper and has bothXComCreateBodyandXComUpdateBodydelegate to it, so create and update apply the samepayload-key check from a single source. A parametrized test mirroring the
existing
test_create_xcom_entry_blocks_forbidden_keyscovers the PATCH path.The three regenerated files (
_private_ui.yaml,schemas.gen.ts,types.gen.ts) are pre-commit catch-up for an unrelatedExtraMenuItemdescription that had drifted on
main; they aren't part of the substantivechange.
^ Add meaningful description above
TestPatchXComEntry::test_patch_xcom_entry_blocks_forbidden_keyscovers the three reserved-key shapes and asserts HTTP 422 with"reserved serialization keys"in the detail.TestCreateXComEntry::test_create_xcom_entry_blocks_forbidden_keysstill passes — create-side error message is byte-identical, behaviour preserved.TestPatchXComEntrycases all pass (valid update, complex object, integer, list, not-found, slash-key, int-type-preservation).prek run --files <changed files>clean and idempotent.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Opus 4.7 (1M context) following the guidelines at
https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions