Skip to content

Commit e1937f0

Browse files
pierrejeambrunkaxil
authored andcommitted
[v3-0-test] Fix patch_task_instance endpoint (#50550) (#50591)
* Fix patch_task_instance endpoint (#50550) (cherry picked from commit db89cc0) * Fix CI
1 parent d391d02 commit e1937f0

File tree

6 files changed

+236
-191
lines changed

6 files changed

+236
-191
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
@@ -4484,8 +4484,9 @@ paths:
44844484
in: query
44854485
required: false
44864486
schema:
4487-
type: integer
4488-
default: -1
4487+
anyOf:
4488+
- type: integer
4489+
- type: 'null'
44894490
title: Map Index
44904491
- name: update_mask
44914492
in: query
@@ -4509,7 +4510,7 @@ paths:
45094510
content:
45104511
application/json:
45114512
schema:
4512-
$ref: '#/components/schemas/TaskInstanceResponse'
4513+
$ref: '#/components/schemas/TaskInstanceCollectionResponse'
45134514
'401':
45144515
content:
45154516
application/json:
@@ -5131,7 +5132,9 @@ paths:
51315132
in: path
51325133
required: true
51335134
schema:
5134-
type: integer
5135+
anyOf:
5136+
- type: integer
5137+
- type: 'null'
51355138
title: Map Index
51365139
- name: update_mask
51375140
in: query
@@ -5155,7 +5158,7 @@ paths:
51555158
content:
51565159
application/json:
51575160
schema:
5158-
$ref: '#/components/schemas/TaskInstanceResponse'
5161+
$ref: '#/components/schemas/TaskInstanceCollectionResponse'
51595162
'401':
51605163
content:
51615164
application/json:
@@ -5724,7 +5727,9 @@ paths:
57245727
in: path
57255728
required: true
57265729
schema:
5727-
type: integer
5730+
anyOf:
5731+
- type: integer
5732+
- type: 'null'
57285733
title: Map Index
57295734
- name: update_mask
57305735
in: query
@@ -5811,8 +5816,9 @@ paths:
58115816
in: query
58125817
required: false
58135818
schema:
5814-
type: integer
5815-
default: -1
5819+
anyOf:
5820+
- type: integer
5821+
- type: 'null'
58165822
title: Map Index
58175823
- name: update_mask
58185824
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
@@ -790,10 +790,13 @@ def patch_task_instance_dry_run(
790790
dag_bag: DagBagDep,
791791
body: PatchTaskInstanceBody,
792792
session: SessionDep,
793-
map_index: int = -1,
793+
map_index: int | None = None,
794794
update_mask: list[str] | None = Query(None),
795795
) -> TaskInstanceCollectionResponse:
796796
"""Update a task instance dry_run mode."""
797+
if map_index is None:
798+
map_index = -1
799+
797800
dag, ti, data = _patch_ti_validate_request(
798801
dag_id, dag_run_id, task_id, dag_bag, body, session, map_index, update_mask
799802
)
@@ -859,10 +862,13 @@ def patch_task_instance(
859862
body: PatchTaskInstanceBody,
860863
user: GetUserDep,
861864
session: SessionDep,
862-
map_index: int = -1,
865+
map_index: int | None = None,
863866
update_mask: list[str] | None = Query(None),
864-
) -> TaskInstanceResponse:
867+
) -> TaskInstanceCollectionResponse:
865868
"""Update a task instance."""
869+
if map_index is None:
870+
map_index = -1
871+
866872
dag, ti, data = _patch_ti_validate_request(
867873
dag_id, dag_run_id, task_id, dag_bag, body, session, map_index, update_mask
868874
)
@@ -909,4 +915,11 @@ def patch_task_instance(
909915
ti.task_instance_note.user_id = user.get_id()
910916
session.commit()
911917

912-
return TaskInstanceResponse.model_validate(ti)
918+
return TaskInstanceCollectionResponse(
919+
task_instances=[
920+
TaskInstanceResponse.model_validate(
921+
ti,
922+
)
923+
],
924+
total_entries=1,
925+
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4001,7 +4001,7 @@ export const useDagServicePatchDag = <
40014001
* @param data.requestBody
40024002
* @param data.mapIndex
40034003
* @param data.updateMask
4004-
* @returns TaskInstanceResponse Successful Response
4004+
* @returns TaskInstanceCollectionResponse Successful Response
40054005
* @throws ApiError
40064006
*/
40074007
export const useTaskInstanceServicePatchTaskInstance = <
@@ -4060,7 +4060,7 @@ export const useTaskInstanceServicePatchTaskInstance = <
40604060
* @param data.mapIndex
40614061
* @param data.requestBody
40624062
* @param data.updateMask
4063-
* @returns TaskInstanceResponse Successful Response
4063+
* @returns TaskInstanceCollectionResponse Successful Response
40644064
* @throws ApiError
40654065
*/
40664066
export const useTaskInstanceServicePatchTaskInstance1 = <

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
@@ -1918,7 +1918,7 @@ export class TaskInstanceService {
19181918
* @param data.requestBody
19191919
* @param data.mapIndex
19201920
* @param data.updateMask
1921-
* @returns TaskInstanceResponse Successful Response
1921+
* @returns TaskInstanceCollectionResponse Successful Response
19221922
* @throws ApiError
19231923
*/
19241924
public static patchTaskInstance(data: PatchTaskInstanceData): CancelablePromise<PatchTaskInstanceResponse> {
@@ -2192,7 +2192,7 @@ export class TaskInstanceService {
21922192
* @param data.mapIndex
21932193
* @param data.requestBody
21942194
* @param data.updateMask
2195-
* @returns TaskInstanceResponse Successful Response
2195+
* @returns TaskInstanceCollectionResponse Successful Response
21962196
* @throws ApiError
21972197
*/
21982198
public static patchTaskInstance1(

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
@@ -2197,13 +2197,13 @@ export type GetTaskInstanceResponse = TaskInstanceResponse;
21972197
export type PatchTaskInstanceData = {
21982198
dagId: string;
21992199
dagRunId: string;
2200-
mapIndex?: number;
2200+
mapIndex?: number | null;
22012201
requestBody: PatchTaskInstanceBody;
22022202
taskId: string;
22032203
updateMask?: Array<string> | null;
22042204
};
22052205

2206-
export type PatchTaskInstanceResponse = TaskInstanceResponse;
2206+
export type PatchTaskInstanceResponse = TaskInstanceCollectionResponse;
22072207

22082208
export type GetMappedTaskInstancesData = {
22092209
dagId: string;
@@ -2281,13 +2281,13 @@ export type GetMappedTaskInstanceResponse = TaskInstanceResponse;
22812281
export type PatchTaskInstance1Data = {
22822282
dagId: string;
22832283
dagRunId: string;
2284-
mapIndex: number;
2284+
mapIndex: number | null;
22852285
requestBody: PatchTaskInstanceBody;
22862286
taskId: string;
22872287
updateMask?: Array<string> | null;
22882288
};
22892289

2290-
export type PatchTaskInstance1Response = TaskInstanceResponse;
2290+
export type PatchTaskInstance1Response = TaskInstanceCollectionResponse;
22912291

22922292
export type GetTaskInstancesData = {
22932293
dagId: string;
@@ -2356,7 +2356,7 @@ export type PostClearTaskInstancesResponse = TaskInstanceCollectionResponse;
23562356
export type PatchTaskInstanceDryRunData = {
23572357
dagId: string;
23582358
dagRunId: string;
2359-
mapIndex: number;
2359+
mapIndex: number | null;
23602360
requestBody: PatchTaskInstanceBody;
23612361
taskId: string;
23622362
updateMask?: Array<string> | null;
@@ -2367,7 +2367,7 @@ export type PatchTaskInstanceDryRunResponse = TaskInstanceCollectionResponse;
23672367
export type PatchTaskInstanceDryRun1Data = {
23682368
dagId: string;
23692369
dagRunId: string;
2370-
mapIndex?: number;
2370+
mapIndex?: number | null;
23712371
requestBody: PatchTaskInstanceBody;
23722372
taskId: string;
23732373
updateMask?: Array<string> | null;
@@ -4198,7 +4198,7 @@ export type $OpenApiTs = {
41984198
/**
41994199
* Successful Response
42004200
*/
4201-
200: TaskInstanceResponse;
4201+
200: TaskInstanceCollectionResponse;
42024202
/**
42034203
* Bad Request
42044204
*/
@@ -4393,7 +4393,7 @@ export type $OpenApiTs = {
43934393
/**
43944394
* Successful Response
43954395
*/
4396-
200: TaskInstanceResponse;
4396+
200: TaskInstanceCollectionResponse;
43974397
/**
43984398
* Bad Request
43994399
*/

0 commit comments

Comments
 (0)