Copilot commented on code in PR #63994:
URL: https://github.com/apache/airflow/pull/63994#discussion_r3042568768


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/variables.py:
##########
@@ -147,21 +149,33 @@ def patch_variable(
     update_mask: list[str] | None = Query(None),
 ) -> VariableResponse:
     """Update a variable by key."""
+    if patch_body.team_name is not None and not conf.getboolean("core", 
"multi_team"):
+        raise HTTPException(
+            status.HTTP_400_BAD_REQUEST,
+            MULTI_TEAM_ERROR_MESSAGE,
+        )
+
     variable = update_orm_from_pydantic(variable_key, patch_body, update_mask, 
session)
     return variable
 
 
 @variables_router.post(
     "",
     status_code=status.HTTP_201_CREATED,
-    responses=create_openapi_http_exception_doc([status.HTTP_409_CONFLICT]),
+    responses=create_openapi_http_exception_doc([status.HTTP_400_BAD_REQUEST, 
status.HTTP_409_CONFLICT]),
     dependencies=[Depends(action_logging()), 
Depends(requires_access_variable("POST"))],
 )
 def post_variable(
     post_body: VariableBody,
     session: SessionDep,
 ) -> VariableResponse:
     """Create a variable."""
+    if post_body.team_name is not None and not conf.getboolean("core", 
"multi_team"):
+        raise HTTPException(
+            status.HTTP_400_BAD_REQUEST,
+            MULTI_TEAM_ERROR_MESSAGE,
+        )

Review Comment:
   The PR description says this is implemented via Pydantic validators and will 
return a 422, but the actual implementation here is a route-level 
`HTTPException` that returns 400. Please either (a) update the PR description 
and motivation screenshots/examples to match the 400 behavior, or (b) move this 
validation into the relevant Pydantic request models (so it becomes a 422 
validation error) and remove the duplicated route-level checks.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to