amoghrajesh commented on code in PR #67547:
URL: https://github.com/apache/airflow/pull/67547#discussion_r3309149569


##########
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_task_state.py:
##########
@@ -191,6 +193,18 @@ def test_overwrites_existing_key(self, test_client):
     def test_empty_body_returns_422(self, test_client):
         assert test_client.put(f"{BASE_URL}/job_id", json={}).status_code == 
422
 
+    def test_null_value_returns_422(self, test_client):
+        assert test_client.put(f"{BASE_URL}/job_id", json={"value": 
None}).status_code == 422
+
+    @pytest.mark.parametrize("bad_float", [float("nan"), float("inf"), 
float("-inf")])
+    def test_non_finite_float_returns_422(self, test_client, bad_float):
+        with pytest.raises(ValueError, match="Out of range float values are 
not JSON compliant"):

Review Comment:
   Handled in 1e8e0ea38c



##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/task_state.py:
##########
@@ -42,4 +46,15 @@ class TaskStateCollectionResponse(BaseModel):
 class TaskStateBody(StrictBaseModel):
     """Request body for setting a task state value."""
 
-    value: str = Field(max_length=65535)
+    value: JsonValue
+
+    @field_validator("value")
+    @classmethod
+    def value_is_json_representable(cls, v: JsonValue) -> JsonValue:
+        if v is None:
+            raise ValueError("value cannot be null")
+        if isinstance(v, float) and not math.isfinite(v):
+            raise ValueError("value must be a finite number; NaN and Inf are 
not JSON representable")
+        if len(json.dumps(v)) > _MAX_SERIALIZED_BYTES:

Review Comment:
   Handled in 1e8e0ea38c



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