wenjin272 commented on code in PR #1474:
URL: https://github.com/apache/flink-agents/pull/1474#discussion_r4739241945


##########
python/flink_agents/integrations/mcp/mcp.py:
##########
@@ -183,6 +262,35 @@ def validate_timeout(cls, value: Any) -> timedelta:
             raise ValueError(msg)
         return duration
 
+    @field_validator("max_retries", mode="before")
+    @classmethod
+    def validate_max_retries(cls, value: Any) -> int:
+        """Validate that max_retries is a non-negative integer."""
+        if isinstance(value, bool) or not isinstance(value, int) or value < 0:
+            msg = f"max_retries must be a non-negative integer, but was 
{value!r}."
+            raise ValueError(msg)
+        return value

Review Comment:
   Could we use `Field(ge=0, strict=True)` for `max_retries` and 
`Field(ge=timedelta(0))` for the backoff fields? This would replace 
`validate_max_retries` and let `validate_backoff` focus on the existing 
`parse_duration()` conversion, which is still needed for inputs such as `100 
ms`. The model validator can retain the `max_backoff >= initial_backoff` check.



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