diff --git a/airflow/api_fastapi/core_api/openapi/v1-generated.yaml b/airflow/api_fastapi/core_api/openapi/v1-generated.yaml index 939d9be2db9b3..efab8e9c1bc4e 100644 --- a/airflow/api_fastapi/core_api/openapi/v1-generated.yaml +++ b/airflow/api_fastapi/core_api/openapi/v1-generated.yaml @@ -5589,6 +5589,12 @@ paths: schema: $ref: '#/components/schemas/HTTPExceptionResponse' description: Forbidden + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPExceptionResponse' + description: Created '404': content: application/json: diff --git a/airflow/api_fastapi/core_api/routes/public/dag_parsing.py b/airflow/api_fastapi/core_api/routes/public/dag_parsing.py index a41d01ec5d32f..4f8d7d4be342f 100644 --- a/airflow/api_fastapi/core_api/routes/public/dag_parsing.py +++ b/airflow/api_fastapi/core_api/routes/public/dag_parsing.py @@ -22,7 +22,7 @@ from fastapi import Depends, HTTPException, Request, status from fastapi.responses import Response from itsdangerous import BadSignature, URLSafeSerializer -from sqlalchemy import exc, select +from sqlalchemy import select from sqlalchemy.orm import Session from airflow.api_fastapi.common.db.common import get_session @@ -40,13 +40,13 @@ @dag_parsing_router.put( "", - responses=create_openapi_http_exception_doc([status.HTTP_404_NOT_FOUND]), + responses=create_openapi_http_exception_doc([status.HTTP_404_NOT_FOUND, status.HTTP_201_CREATED]), ) def reparse_dag_file( file_token: str, session: Annotated[Session, Depends(get_session)], request: Request, -) -> Response: +): """Request re-parsing a DAG file.""" secret_key = request.app.state.secret_key auth_s = URLSafeSerializer(secret_key) @@ -64,9 +64,4 @@ def reparse_dag_file( parsing_request = DagPriorityParsingRequest(fileloc=path) session.add(parsing_request) - try: - session.commit() - except exc.IntegrityError: - session.rollback() - return Response("Duplicate request", status_code=status.HTTP_201_CREATED) return Response(status_code=status.HTTP_201_CREATED) diff --git a/airflow/ui/openapi-gen/queries/queries.ts b/airflow/ui/openapi-gen/queries/queries.ts index e8d9b95f73d2a..c3108df6b7517 100644 --- a/airflow/ui/openapi-gen/queries/queries.ts +++ b/airflow/ui/openapi-gen/queries/queries.ts @@ -3137,6 +3137,7 @@ export const useBackfillServiceCancelBackfill = < * @param data The data for the request. * @param data.fileToken * @returns unknown Successful Response + * @returns HTTPExceptionResponse Created * @throws ApiError */ export const useDagParsingServiceReparseDagFile = < diff --git a/airflow/ui/openapi-gen/requests/services.gen.ts b/airflow/ui/openapi-gen/requests/services.gen.ts index 7a494dacba7ee..1d9fd6a819cdb 100644 --- a/airflow/ui/openapi-gen/requests/services.gen.ts +++ b/airflow/ui/openapi-gen/requests/services.gen.ts @@ -170,8 +170,6 @@ import type { GetVariablesResponse, PostVariableData, PostVariableResponse, - GetXcomEntryData, - GetXcomEntryResponse, ReparseDagFileData, ReparseDagFileResponse, GetHealthResponse, @@ -2934,49 +2932,6 @@ export class VariableService { } } -export class XcomService { - /** - * Get Xcom Entry - * Get an XCom entry. - * @param data The data for the request. - * @param data.dagId - * @param data.taskId - * @param data.dagRunId - * @param data.xcomKey - * @param data.mapIndex - * @param data.deserialize - * @param data.stringify - * @returns unknown Successful Response - * @throws ApiError - */ - public static getXcomEntry( - data: GetXcomEntryData, - ): CancelablePromise<GetXcomEntryResponse> { - return __request(OpenAPI, { - method: "GET", - url: "/public/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/xcomEntries/{xcom_key}", - path: { - dag_id: data.dagId, - task_id: data.taskId, - dag_run_id: data.dagRunId, - xcom_key: data.xcomKey, - }, - query: { - map_index: data.mapIndex, - deserialize: data.deserialize, - stringify: data.stringify, - }, - errors: { - 400: "Bad Request", - 401: "Unauthorized", - 403: "Forbidden", - 404: "Not Found", - 422: "Validation Error", - }, - }); - } -} - export class DagParsingService { /** * Reparse Dag File @@ -2984,6 +2939,7 @@ export class DagParsingService { * @param data The data for the request. * @param data.fileToken * @returns unknown Successful Response + * @returns HTTPExceptionResponse Created * @throws ApiError */ public static reparseDagFile( diff --git a/airflow/ui/openapi-gen/requests/types.gen.ts b/airflow/ui/openapi-gen/requests/types.gen.ts index aa11ffd8d550e..c10311dd91ee0 100644 --- a/airflow/ui/openapi-gen/requests/types.gen.ts +++ b/airflow/ui/openapi-gen/requests/types.gen.ts @@ -1980,23 +1980,11 @@ export type PostVariableData = { export type PostVariableResponse = VariableResponse; -export type GetXcomEntryData = { - dagId: string; - dagRunId: string; - deserialize?: boolean; - mapIndex?: number; - stringify?: boolean; - taskId: string; - xcomKey: string; -}; - -export type GetXcomEntryResponse = XComResponseNative | XComResponseString; - export type ReparseDagFileData = { fileToken: string; }; -export type ReparseDagFileResponse = unknown; +export type ReparseDagFileResponse = unknown | HTTPExceptionResponse; export type GetHealthResponse = HealthInfoSchema; @@ -4260,37 +4248,6 @@ export type $OpenApiTs = { }; }; }; - "/public/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/xcomEntries/{xcom_key}": { - get: { - req: GetXcomEntryData; - res: { - /** - * Successful Response - */ - 200: XComResponseNative | XComResponseString; - /** - * Bad Request - */ - 400: HTTPExceptionResponse; - /** - * Unauthorized - */ - 401: HTTPExceptionResponse; - /** - * Forbidden - */ - 403: HTTPExceptionResponse; - /** - * Not Found - */ - 404: HTTPExceptionResponse; - /** - * Validation Error - */ - 422: HTTPValidationError; - }; - }; - }; "/public/parseDagFile/{file_token}": { put: { req: ReparseDagFileData; @@ -4299,6 +4256,10 @@ export type $OpenApiTs = { * Successful Response */ 200: unknown; + /** + * Created + */ + 201: HTTPExceptionResponse; /** * Unauthorized */ diff --git a/tests/api_connexion/endpoints/test_dag_parsing.py b/tests/api_connexion/endpoints/test_dag_parsing.py index e12d521c27242..e92a3b916873e 100644 --- a/tests/api_connexion/endpoints/test_dag_parsing.py +++ b/tests/api_connexion/endpoints/test_dag_parsing.py @@ -57,7 +57,7 @@ def configured_app(minimal_app_for_api): delete_user(app, username="test_no_permissions") -class TestDagParsingRequest: +class TestDagParsingEndpoint: @pytest.fixture(autouse=True) def setup_attrs(self, configured_app) -> None: self.app = configured_app