This is an automated email from the ASF dual-hosted git repository.
pierrejeambrun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new a4357ca25c Fix: make dry run optional for patch task instance (#34568)
a4357ca25c is described below
commit a4357ca25cc3d014e50968bac7858f533e6421e4
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
---
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 f76cfc7baa..48c9e5e023 100644
--- a/airflow/api_connexion/openapi/v1.yaml
+++ b/airflow/api_connexion/openapi/v1.yaml
@@ -4308,7 +4308,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:
$ref: '#/components/schemas/UpdateTaskState'
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 118804e290..ec10084385 100644
--- a/airflow/www/static/js/types/api-generated.ts
+++ b/airflow/www/static/js/types/api-generated.ts
@@ -1904,7 +1904,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;
new_state?: components["schemas"]["UpdateTaskState"];
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