From f957ac4b768f5d07a94f7f50bd7e31dd2f19107d Mon Sep 17 00:00:00 2001 From: Bugra Ozturk Date: Mon, 23 Dec 2024 14:08:35 +0100 Subject: [PATCH] Remove None from param definition, adjust the log of wrong DagRun type in parameters and test --- airflow/api_fastapi/common/parameters.py | 6 +++--- .../core_api/openapi/v1-generated.yaml | 16 ++++------------ airflow/ui/openapi-gen/requests/types.gen.ts | 8 ++++---- .../api_fastapi/core_api/routes/ui/test_grid.py | 2 +- 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/airflow/api_fastapi/common/parameters.py b/airflow/api_fastapi/common/parameters.py index f74450a0d5f78..376b88462d6e3 100644 --- a/airflow/api_fastapi/common/parameters.py +++ b/airflow/api_fastapi/common/parameters.py @@ -538,7 +538,7 @@ def _transform_dag_run_types(types: list[str] | None) -> list[DagRunType | None] except ValueError: raise HTTPException( status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, - detail=f"Invalid value for state. Valid values are {', '.join(DagRunType)}", + detail=f"Invalid value for run type. Valid values are {', '.join(DagRunType)}", ) @@ -635,8 +635,8 @@ def _optional_boolean(value: bool | None) -> bool | None: return value if value is not None else False -QueryIncludeUpstream = Annotated[Union[bool, None], AfterValidator(_optional_boolean)] -QueryIncludeDownstream = Annotated[Union[bool, None], AfterValidator(_optional_boolean)] +QueryIncludeUpstream = Annotated[Union[bool], AfterValidator(_optional_boolean)] +QueryIncludeDownstream = Annotated[Union[bool], AfterValidator(_optional_boolean)] state_priority: list[None | TaskInstanceState] = [ TaskInstanceState.FAILED, diff --git a/airflow/api_fastapi/core_api/openapi/v1-generated.yaml b/airflow/api_fastapi/core_api/openapi/v1-generated.yaml index f4565fc18e339..008e4112c3f35 100644 --- a/airflow/api_fastapi/core_api/openapi/v1-generated.yaml +++ b/airflow/api_fastapi/core_api/openapi/v1-generated.yaml @@ -222,18 +222,14 @@ paths: in: query required: false schema: - anyOf: - - type: boolean - - type: 'null' + type: boolean default: false title: Include Upstream - name: include_downstream in: query required: false schema: - anyOf: - - type: boolean - - type: 'null' + type: boolean default: false title: Include Downstream - name: root @@ -353,18 +349,14 @@ paths: in: query required: false schema: - anyOf: - - type: boolean - - type: 'null' + type: boolean default: false title: Include Upstream - name: include_downstream in: query required: false schema: - anyOf: - - type: boolean - - type: 'null' + type: boolean default: false title: Include Downstream - name: logical_date_gte diff --git a/airflow/ui/openapi-gen/requests/types.gen.ts b/airflow/ui/openapi-gen/requests/types.gen.ts index a90d497da8e68..f7bfd1c0d26d9 100644 --- a/airflow/ui/openapi-gen/requests/types.gen.ts +++ b/airflow/ui/openapi-gen/requests/types.gen.ts @@ -1509,8 +1509,8 @@ export type HistoricalMetricsResponse = HistoricalMetricDataResponse; export type StructureDataData = { dagId: string; externalDependencies?: boolean; - includeDownstream?: boolean | null; - includeUpstream?: boolean | null; + includeDownstream?: boolean; + includeUpstream?: boolean; root?: string | null; }; @@ -1567,8 +1567,8 @@ export type CancelBackfillResponse = BackfillResponse; export type GridDataData = { dagId: string; - includeDownstream?: boolean | null; - includeUpstream?: boolean | null; + includeDownstream?: boolean; + includeUpstream?: boolean; limit?: number; logicalDateGte?: string | null; logicalDateLte?: string | null; diff --git a/tests/api_fastapi/core_api/routes/ui/test_grid.py b/tests/api_fastapi/core_api/routes/ui/test_grid.py index f879d2f27d6f9..73819323522da 100644 --- a/tests/api_fastapi/core_api/routes/ui/test_grid.py +++ b/tests/api_fastapi/core_api/routes/ui/test_grid.py @@ -2799,7 +2799,7 @@ def test_should_response_200_run_types(self, test_client, run_type, expected): [ ( ["invalid"], - {"detail": f"Invalid value for state. Valid values are {', '.join(DagRunType)}"}, + {"detail": f"Invalid value for run type. Valid values are {', '.join(DagRunType)}"}, ) ], )