bugraoz93 commented on code in PR #55744:
URL: https://github.com/apache/airflow/pull/55744#discussion_r2356942058
##########
airflow-ctl/src/airflowctl/api/operations.py:
##########
@@ -243,8 +243,11 @@ def create_event(
) -> AssetEventResponse | ServerResponseError:
"""Create an asset event."""
try:
+ # Ensure extra is an object; DB/UI choke on null
+ if getattr(asset_event_body, "extra", None) is None:
Review Comment:
```suggestion
if asset_event_body.extra is None:
```
Even though I like `getattr` like safe calls, this actually brings danger to
not fail the unit test. If `extra` is removed or changed name is changed in the
datamodel (Pydantic models), it creates a bug. Because this statement will
return None in that case and we always add extra even though the API already
changed it. This is why we use Pydantic which is kind of a data contract
between the API and the client
You can try the behavior even with a dict
```python
a={}
if getattr(a, "extra", None) is None:
a["extra"] = {}
print(a)
```
--
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]