Lee-W commented on code in PR #74451:
URL: https://github.com/apache/airflow/pull/74451#discussion_r4310928530
##########
providers/common/ai/src/airflow/providers/common/ai/hooks/mcp.py:
##########
@@ -236,13 +237,41 @@ def get_conn(self) -> Any:
raise ValueError(
f"Connection {self.mcp_conn_id!r} requires 'command' in
extra for stdio transport."
)
- args = extra.get("args", [])
- if isinstance(args, str):
- args = [args]
+ args = extra.get("args")
+ if args is None:
+ args = []
+ elif isinstance(args, str):
+ if args.strip().startswith("["):
+ try:
+ args = json.loads(args)
+ except ValueError as e:
+ raise ValueError(
+ f"'args' in extra for connection
{self.mcp_conn_id!r} looks like a JSON array "
+ f"but is not valid JSON: {args!r}."
+ ) from e
+ else:
+ args = [args]
+ if not isinstance(args, list) or not all(isinstance(arg, str) for
arg in args):
+ raise ValueError(
+ f"'args' in extra for connection {self.mcp_conn_id!r} must
be a string, a JSON "
+ f"array of strings or a list of strings, got {args!r}."
Review Comment:
Both the invalid-JSON error and the type-check error no longer include the
`args` value. The type-check error now reports the type, plus the index of the
first non-string item, in the same style as `_validate_env_dict`.
--
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]