Skip to content

Commit fba6f86

Browse files
Allow skipped task state task_instance_schema.py (#31421)
--------- Co-authored-by: Hussein Awala <hussein@awala.fr>
1 parent 2336630 commit fba6f86

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

airflow/api_connexion/openapi/v1.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4265,6 +4265,7 @@ components:
42654265
enum:
42664266
- success
42674267
- failed
4268+
- skipped
42684269

42694270
UpdateTaskInstance:
42704271
type: object
@@ -4282,6 +4283,8 @@ components:
42824283
enum:
42834284
- success
42844285
- failed
4286+
- skipped
4287+
42854288
SetTaskInstanceNote:
42864289
type: object
42874290
required:

airflow/api_connexion/schemas/task_instance_schema.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from airflow.api_connexion.schemas.trigger_schema import TriggerSchema
3131
from airflow.models import SlaMiss, TaskInstance
3232
from airflow.utils.helpers import exactly_one
33-
from airflow.utils.state import State
33+
from airflow.utils.state import TaskInstanceState
3434

3535

3636
class TaskInstanceSchema(SQLAlchemySchema):
@@ -158,7 +158,12 @@ class SetTaskInstanceStateFormSchema(Schema):
158158
include_downstream = fields.Boolean(required=True)
159159
include_future = fields.Boolean(required=True)
160160
include_past = fields.Boolean(required=True)
161-
new_state = TaskInstanceStateField(required=True, validate=validate.OneOf([State.SUCCESS, State.FAILED]))
161+
new_state = TaskInstanceStateField(
162+
required=True,
163+
validate=validate.OneOf(
164+
[TaskInstanceState.SUCCESS, TaskInstanceState.FAILED, TaskInstanceState.SKIPPED]
165+
),
166+
)
162167

163168
@validates_schema
164169
def validate_form(self, data, **kwargs):
@@ -171,7 +176,12 @@ class SetSingleTaskInstanceStateFormSchema(Schema):
171176
"""Schema for handling the request of updating state of a single task instance."""
172177

173178
dry_run = fields.Boolean(dump_default=True)
174-
new_state = TaskInstanceStateField(required=True, validate=validate.OneOf([State.SUCCESS, State.FAILED]))
179+
new_state = TaskInstanceStateField(
180+
required=True,
181+
validate=validate.OneOf(
182+
[TaskInstanceState.SUCCESS, TaskInstanceState.FAILED, TaskInstanceState.SKIPPED]
183+
),
184+
)
175185

176186

177187
class TaskInstanceReferenceSchema(Schema):

airflow/www/static/js/types/api-generated.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,7 +1874,7 @@ export interface components {
18741874
* @description Expected new state.
18751875
* @enum {string}
18761876
*/
1877-
new_state?: "success" | "failed";
1877+
new_state?: "success" | "failed" | "skipped";
18781878
};
18791879
UpdateTaskInstance: {
18801880
/**
@@ -1888,7 +1888,7 @@ export interface components {
18881888
* @description Expected new state.
18891889
* @enum {string}
18901890
*/
1891-
new_state?: "success" | "failed";
1891+
new_state?: "success" | "failed" | "skipped";
18921892
};
18931893
SetTaskInstanceNote: {
18941894
/** @description The custom note to set for this Task Instance. */

tests/api_connexion/endpoints/test_task_instance_endpoint.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,14 +1803,16 @@ def test_should_raise_404_not_found_task(self):
18031803
"dry_run": True,
18041804
"new_state": "failede",
18051805
},
1806-
f"'failede' is not one of ['{State.SUCCESS}', '{State.FAILED}'] - 'new_state'",
1806+
f"'failede' is not one of ['{State.SUCCESS}', '{State.FAILED}', '{State.SKIPPED}']"
1807+
" - 'new_state'",
18071808
),
18081809
(
18091810
{
18101811
"dry_run": True,
18111812
"new_state": "queued",
18121813
},
1813-
f"'queued' is not one of ['{State.SUCCESS}', '{State.FAILED}'] - 'new_state'",
1814+
f"'queued' is not one of ['{State.SUCCESS}', '{State.FAILED}', '{State.SKIPPED}']"
1815+
" - 'new_state'",
18141816
),
18151817
],
18161818
)

0 commit comments

Comments
 (0)