henry3260 commented on code in PR #73753:
URL: https://github.com/apache/airflow/pull/73753#discussion_r4111091316


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/asset_state_store.py:
##########
@@ -172,13 +172,16 @@ def set_asset_state_store(
     session: SessionDep,
 ) -> None:
     """Set an asset state store value. Creates or overwrites the key."""
-    _get_db_backend().set_asset_state_store(
-        AssetScope(asset_id=asset_id),
-        key,
-        json.dumps(body.value),
-        kind=AssetStateStoreWriterKind.API,
-        session=session,
-    )
+    try:
+        _get_db_backend().set_asset_state_store(
+            AssetScope(asset_id=asset_id),
+            key,
+            json.dumps(body.value),
+            kind=AssetStateStoreWriterKind.API,
+            session=session,
+        )
+    except ValueError as e:
+        raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, 
detail=str(e)) from e

Review Comment:
   IIUC, this except ValueError is dead code. The only ValueError here comes 
from validate_writer_fields(), and this route always calls it with kind=API and 
no task fields (dag_id/run_id/task_id/map_index are all None), so the check can 
never fail.



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