pierrejeambrun commented on code in PR #45089:
URL: https://github.com/apache/airflow/pull/45089#discussion_r1893172144
##########
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.",
+ )
Review Comment:
This shouldn't be done manually like that. Pydantic have native validators.
This should do the exact same.
```
Field(max_length=256)
```
--
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]