This is an automated email from the ASF dual-hosted git repository.

ephraimanierobi pushed a commit to branch v2-7-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit c32570f2b473e388a3a8fdc34df92911d06dcd7d
Author: Tyler Calder <[email protected]>
AuthorDate: Sat Sep 30 12:46:56 2023 -0600

    Fix: make dry run optional for patch task instance  (#34568)
    
    * fix: Make dry_run optional per docs
    
    This fixes an issue where dry_run is not actually and optional parameter
    in the patch task_instance api.
    
    * chore: remove formatting changes
    
    * fix: Make changes for api docs
    
    This updates the docs and the code so that they are in alignment while
    also being consistent with all other endpoints. All other Endpoints have
    dry run set to be True by default.
    
    * fix: Update static ts file for api change
    
    * fix: Remove dump_default
    
    (cherry picked from commit a4357ca25cc3d014e50968bac7858f533e6421e4)
---
 airflow/api_connexion/openapi/v1.yaml               |  2 +-
 .../api_connexion/schemas/task_instance_schema.py   |  2 +-
 airflow/www/static/js/types/api-generated.ts        |  2 +-
 .../endpoints/test_task_instance_endpoint.py        | 21 +++++++++++++++++++++
 4 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/airflow/api_connexion/openapi/v1.yaml 
b/airflow/api_connexion/openapi/v1.yaml
index 341b1d78c3..58d5bef9f0 100644
--- a/airflow/api_connexion/openapi/v1.yaml
+++ b/airflow/api_connexion/openapi/v1.yaml
@@ -4307,7 +4307,7 @@ components:
             If set, don't actually run this operation. The response will 
contain the task instance
             planned to be affected, but won't be modified in any way.
           type: boolean
-          default: false
+          default: true
 
         new_state:
           description: Expected new state.
diff --git a/airflow/api_connexion/schemas/task_instance_schema.py 
b/airflow/api_connexion/schemas/task_instance_schema.py
index 1d5fd29665..02dc1fb3f6 100644
--- a/airflow/api_connexion/schemas/task_instance_schema.py
+++ b/airflow/api_connexion/schemas/task_instance_schema.py
@@ -180,7 +180,7 @@ class SetTaskInstanceStateFormSchema(Schema):
 class SetSingleTaskInstanceStateFormSchema(Schema):
     """Schema for handling the request of updating state of a single task 
instance."""
 
-    dry_run = fields.Boolean(dump_default=True)
+    dry_run = fields.Boolean(load_default=True)
     new_state = TaskInstanceStateField(
         required=True,
         validate=validate.OneOf(
diff --git a/airflow/www/static/js/types/api-generated.ts 
b/airflow/www/static/js/types/api-generated.ts
index 8dead88fc7..9477c87db3 100644
--- a/airflow/www/static/js/types/api-generated.ts
+++ b/airflow/www/static/js/types/api-generated.ts
@@ -1908,7 +1908,7 @@ export interface components {
        * @description If set, don't actually run this operation. The response 
will contain the task instance
        * planned to be affected, but won't be modified in any way.
        *
-       * @default false
+       * @default true
        */
       dry_run?: boolean;
       /**
diff --git a/tests/api_connexion/endpoints/test_task_instance_endpoint.py 
b/tests/api_connexion/endpoints/test_task_instance_endpoint.py
index f09b55cf41..5056f7736d 100644
--- a/tests/api_connexion/endpoints/test_task_instance_endpoint.py
+++ b/tests/api_connexion/endpoints/test_task_instance_endpoint.py
@@ -1772,6 +1772,27 @@ class TestPatchTaskInstance(TestTaskInstanceEndpoint):
         assert response2.status_code == 200
         assert response2.json["state"] == NEW_STATE
 
+    def test_should_update_task_instance_state_default_dry_run_to_true(self, 
session):
+        self.create_task_instances(session)
+
+        NEW_STATE = "running"
+
+        self.client.patch(
+            self.ENDPOINT_URL,
+            environ_overrides={"REMOTE_USER": "test"},
+            json={
+                "new_state": NEW_STATE,
+            },
+        )
+
+        response2 = self.client.get(
+            self.ENDPOINT_URL,
+            environ_overrides={"REMOTE_USER": "test"},
+            json={},
+        )
+        assert response2.status_code == 200
+        assert response2.json["state"] == NEW_STATE
+
     def test_should_update_mapped_task_instance_state(self, session):
         NEW_STATE = "failed"
         map_index = 1

Reply via email to