namita-can commented on code in PR #70328:
URL: https://github.com/apache/airflow/pull/70328#discussion_r3779965286
##########
airflow-ctl/tests/airflow_ctl/api/test_operations.py:
##########
@@ -1157,6 +1157,36 @@ def handle_request(request: httpx.Request) ->
httpx.Response:
response = client.dags.trigger(dag_id=self.dag_id,
trigger_dag_run=self.trigger_dag_run)
assert response == self.dag_run_response
+ def test_trigger_excludes_none_fields_from_request_body(self):
+ """Regression test: trigger() must exclude unset (None) fields from the
+ request body. Older API servers reject unrecognized fields (e.g.
+ partition_key, bundle_version, added in a later API version) with a
+ 422 extra_forbidden error if they're present at all, even as null.
+ """
+ captured_body = {}
+
+ def handle_request(request: httpx.Request) -> httpx.Response:
+ nonlocal captured_body
+ captured_body = json.loads(request.content)
+ return httpx.Response(200,
json=json.loads(self.dag_run_response.model_dump_json()))
+
+ client = make_api_client(transport=httpx.MockTransport(handle_request))
+ client.dags.trigger(dag_id=self.dag_id,
trigger_dag_run=self.trigger_dag_run)
+
+ # conf is explicitly defaulted to {} by trigger() when unset, so it's
expected.
+ assert captured_body == {"conf": {}}
+ for field in (
Review Comment:
Reworked the test to assert partition_key/bundle_version are excluded and
logical_date is present.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]