Skip to content

Commit db89cc0

Browse files
Fix patch_task_instance endpoint (#50550)
1 parent 39f215f commit db89cc0

File tree

6 files changed

+241
-196
lines changed

6 files changed

+241
-196
lines changed

airflow-core/src/airflow/api_fastapi/core_api/openapi/v1-rest-api-generated.yaml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4543,8 +4543,9 @@ paths:
45434543
in: query
45444544
required: false
45454545
schema:
4546-
type: integer
4547-
default: -1
4546+
anyOf:
4547+
- type: integer
4548+
- type: 'null'
45484549
title: Map Index
45494550
- name: update_mask
45504551
in: query
@@ -4568,7 +4569,7 @@ paths:
45684569
content:
45694570
application/json:
45704571
schema:
4571-
$ref: '#/components/schemas/TaskInstanceResponse'
4572+
$ref: '#/components/schemas/TaskInstanceCollectionResponse'
45724573
'401':
45734574
content:
45744575
application/json:
@@ -5256,7 +5257,9 @@ paths:
52565257
in: path
52575258
required: true
52585259
schema:
5259-
type: integer
5260+
anyOf:
5261+
- type: integer
5262+
- type: 'null'
52605263
title: Map Index
52615264
- name: update_mask
52625265
in: query
@@ -5280,7 +5283,7 @@ paths:
52805283
content:
52815284
application/json:
52825285
schema:
5283-
$ref: '#/components/schemas/TaskInstanceResponse'
5286+
$ref: '#/components/schemas/TaskInstanceCollectionResponse'
52845287
'401':
52855288
content:
52865289
application/json:
@@ -5853,7 +5856,9 @@ paths:
58535856
in: path
58545857
required: true
58555858
schema:
5856-
type: integer
5859+
anyOf:
5860+
- type: integer
5861+
- type: 'null'
58575862
title: Map Index
58585863
- name: update_mask
58595864
in: query
@@ -5940,8 +5945,9 @@ paths:
59405945
in: query
59415946
required: false
59425947
schema:
5943-
type: integer
5944-
default: -1
5948+
anyOf:
5949+
- type: integer
5950+
- type: 'null'
59455951
title: Map Index
59465952
- name: update_mask
59475953
in: query

airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -803,10 +803,13 @@ def patch_task_instance_dry_run(
803803
dag_bag: DagBagDep,
804804
body: PatchTaskInstanceBody,
805805
session: SessionDep,
806-
map_index: int = -1,
806+
map_index: int | None = None,
807807
update_mask: list[str] | None = Query(None),
808808
) -> TaskInstanceCollectionResponse:
809809
"""Update a task instance dry_run mode."""
810+
if map_index is None:
811+
map_index = -1
812+
810813
dag, ti, data = _patch_ti_validate_request(
811814
dag_id, dag_run_id, task_id, dag_bag, body, session, map_index, update_mask
812815
)
@@ -874,10 +877,13 @@ def patch_task_instance(
874877
body: PatchTaskInstanceBody,
875878
user: GetUserDep,
876879
session: SessionDep,
877-
map_index: int = -1,
880+
map_index: int | None = None,
878881
update_mask: list[str] | None = Query(None),
879-
) -> TaskInstanceResponse:
882+
) -> TaskInstanceCollectionResponse:
880883
"""Update a task instance."""
884+
if map_index is None:
885+
map_index = -1
886+
881887
dag, ti, data = _patch_ti_validate_request(
882888
dag_id, dag_run_id, task_id, dag_bag, body, session, map_index, update_mask
883889
)
@@ -924,7 +930,14 @@ def patch_task_instance(
924930
ti.task_instance_note.user_id = user.get_id()
925931
session.commit()
926932

927-
return TaskInstanceResponse.model_validate(ti)
933+
return TaskInstanceCollectionResponse(
934+
task_instances=[
935+
TaskInstanceResponse.model_validate(
936+
ti,
937+
)
938+
],
939+
total_entries=1,
940+
)
928941

929942

930943
@task_instances_router.delete(

airflow-core/src/airflow/ui/openapi-gen/queries/queries.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4066,7 +4066,7 @@ export const useDagServicePatchDag = <
40664066
* @param data.requestBody
40674067
* @param data.mapIndex
40684068
* @param data.updateMask
4069-
* @returns TaskInstanceResponse Successful Response
4069+
* @returns TaskInstanceCollectionResponse Successful Response
40704070
* @throws ApiError
40714071
*/
40724072
export const useTaskInstanceServicePatchTaskInstance = <
@@ -4125,7 +4125,7 @@ export const useTaskInstanceServicePatchTaskInstance = <
41254125
* @param data.mapIndex
41264126
* @param data.requestBody
41274127
* @param data.updateMask
4128-
* @returns TaskInstanceResponse Successful Response
4128+
* @returns TaskInstanceCollectionResponse Successful Response
41294129
* @throws ApiError
41304130
*/
41314131
export const useTaskInstanceServicePatchTaskInstanceByMapIndex = <

airflow-core/src/airflow/ui/openapi-gen/requests/services.gen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,7 +1923,7 @@ export class TaskInstanceService {
19231923
* @param data.requestBody
19241924
* @param data.mapIndex
19251925
* @param data.updateMask
1926-
* @returns TaskInstanceResponse Successful Response
1926+
* @returns TaskInstanceCollectionResponse Successful Response
19271927
* @throws ApiError
19281928
*/
19291929
public static patchTaskInstance(data: PatchTaskInstanceData): CancelablePromise<PatchTaskInstanceResponse> {
@@ -2231,7 +2231,7 @@ export class TaskInstanceService {
22312231
* @param data.mapIndex
22322232
* @param data.requestBody
22332233
* @param data.updateMask
2234-
* @returns TaskInstanceResponse Successful Response
2234+
* @returns TaskInstanceCollectionResponse Successful Response
22352235
* @throws ApiError
22362236
*/
22372237
public static patchTaskInstanceByMapIndex(

airflow-core/src/airflow/ui/openapi-gen/requests/types.gen.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,13 +2270,13 @@ export type GetTaskInstanceResponse = TaskInstanceResponse;
22702270
export type PatchTaskInstanceData = {
22712271
dagId: string;
22722272
dagRunId: string;
2273-
mapIndex?: number;
2273+
mapIndex?: number | null;
22742274
requestBody: PatchTaskInstanceBody;
22752275
taskId: string;
22762276
updateMask?: Array<string> | null;
22772277
};
22782278

2279-
export type PatchTaskInstanceResponse = TaskInstanceResponse;
2279+
export type PatchTaskInstanceResponse = TaskInstanceCollectionResponse;
22802280

22812281
export type DeleteTaskInstanceData = {
22822282
dagId: string;
@@ -2363,13 +2363,13 @@ export type GetMappedTaskInstanceResponse = TaskInstanceResponse;
23632363
export type PatchTaskInstanceByMapIndexData = {
23642364
dagId: string;
23652365
dagRunId: string;
2366-
mapIndex: number;
2366+
mapIndex: number | null;
23672367
requestBody: PatchTaskInstanceBody;
23682368
taskId: string;
23692369
updateMask?: Array<string> | null;
23702370
};
23712371

2372-
export type PatchTaskInstanceByMapIndexResponse = TaskInstanceResponse;
2372+
export type PatchTaskInstanceByMapIndexResponse = TaskInstanceCollectionResponse;
23732373

23742374
export type GetTaskInstancesData = {
23752375
dagId: string;
@@ -2441,7 +2441,7 @@ export type PostClearTaskInstancesResponse = TaskInstanceCollectionResponse;
24412441
export type PatchTaskInstanceDryRunByMapIndexData = {
24422442
dagId: string;
24432443
dagRunId: string;
2444-
mapIndex: number;
2444+
mapIndex: number | null;
24452445
requestBody: PatchTaskInstanceBody;
24462446
taskId: string;
24472447
updateMask?: Array<string> | null;
@@ -2452,7 +2452,7 @@ export type PatchTaskInstanceDryRunByMapIndexResponse = TaskInstanceCollectionRe
24522452
export type PatchTaskInstanceDryRunData = {
24532453
dagId: string;
24542454
dagRunId: string;
2455-
mapIndex?: number;
2455+
mapIndex?: number | null;
24562456
requestBody: PatchTaskInstanceBody;
24572457
taskId: string;
24582458
updateMask?: Array<string> | null;
@@ -4307,7 +4307,7 @@ export type $OpenApiTs = {
43074307
/**
43084308
* Successful Response
43094309
*/
4310-
200: TaskInstanceResponse;
4310+
200: TaskInstanceCollectionResponse;
43114311
/**
43124312
* Bad Request
43134313
*/
@@ -4527,7 +4527,7 @@ export type $OpenApiTs = {
45274527
/**
45284528
* Successful Response
45294529
*/
4530-
200: TaskInstanceResponse;
4530+
200: TaskInstanceCollectionResponse;
45314531
/**
45324532
* Bad Request
45334533
*/

0 commit comments

Comments
 (0)