pierrejeambrun commented on code in PR #42508:
URL: https://github.com/apache/airflow/pull/42508#discussion_r1778314843


##########
airflow/api_fastapi/views/public/dags.py:
##########
@@ -71,16 +72,13 @@ async def get_dags(
 
     dags = session.scalars(dags_query).all()
 
-    try:
-        return DAGCollectionResponse(
-            dags=[DAGResponse.model_validate(dag, from_attributes=True) for 
dag in dags],
-            total_entries=total_entries,
-        )
-    except ValueError as e:

Review Comment:
   Good question. This was taken from the equivalent flask code, but basically 
we use a pydantic model to validate and convert data to a pydantic instance. 
Both the constructor (`__init__`)and the `model_validate` only raise 
`ValidationError` isf the data can't be validated. (confirmed by their 
docstring)
   
   Yes `ValidationError` will yield a 422 response and are nativelly handled by 
FastAPI so nothing more to do here.
   
   That piece of code would need to remain if we could find a case that 
actually raises a ValueError, but I don't. And ValueError would raise a 500 
internal error for the client. We don't have an exception handler for 
ValueError. I think that part was relevant maybe when we had the `fields` query 
param do only serialize a partial response but that has been removed for now, 
because not trivial to do.



-- 
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