jscheffl commented on code in PR #45089:
URL: https://github.com/apache/airflow/pull/45089#discussion_r1893041434
##########
airflow/api_fastapi/core_api/routes/public/variables.py:
##########
@@ -166,6 +167,21 @@ def post_variable(
session: SessionDep,
) -> VariableResponse:
"""Create a variable."""
+ # Check for key length limit
+ if len(post_body.key) > ID_LEN:
+ raise HTTPException(
+ status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
+ detail=f"Variable key exceeds maximum length of {ID_LEN}
characters.",
+ )
+
+ # Check if the key already exists
+ existing_variable = session.scalar(select(Variable).where(Variable.key ==
post_body.key).limit(1))
+ if existing_variable:
+ raise HTTPException(
+ status_code=status.HTTP_409_CONFLICT,
Review Comment:
I think the error 409 need to be added to the decorator to be also added to
the OpenAPI spec and therefore to be into the client generated code
--
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]