mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-20 04:24:17 +02:00
Fix transform arg collisions with passthrough params (#3431)
🤖 Generated with GPT-5.2-Codex
This commit is contained in:
parent
901d8cdd60
commit
d316f193a8
2 changed files with 24 additions and 6 deletions
|
|
@ -554,12 +554,16 @@ class TransformedTool(Tool):
|
|||
# Additional validation: check for naming conflicts after transformation
|
||||
if transform_args:
|
||||
new_names = []
|
||||
for old_name, transform in transform_args.items():
|
||||
if not transform.hide:
|
||||
if transform.name is not NotSet:
|
||||
new_names.append(transform.name)
|
||||
else:
|
||||
new_names.append(old_name)
|
||||
for old_name in parent_params:
|
||||
transform = transform_args.get(old_name, ArgTransform())
|
||||
|
||||
if transform.hide:
|
||||
continue
|
||||
|
||||
if transform.name is not NotSet:
|
||||
new_names.append(transform.name)
|
||||
else:
|
||||
new_names.append(old_name)
|
||||
|
||||
# Check for duplicate names after transformation
|
||||
name_counts = {}
|
||||
|
|
|
|||
|
|
@ -482,6 +482,20 @@ def test_transform_args_creates_duplicate_names(add_tool):
|
|||
)
|
||||
|
||||
|
||||
def test_transform_args_collision_with_passthrough_name(add_tool):
|
||||
"""Test that renaming to a passthrough parameter name raises ValueError."""
|
||||
with pytest.raises(
|
||||
ValueError,
|
||||
match="Multiple arguments would be mapped to the same names: old_y",
|
||||
):
|
||||
Tool.from_tool(
|
||||
add_tool,
|
||||
transform_args={
|
||||
"old_x": ArgTransform(name="old_y"),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def test_function_without_kwargs_missing_params(add_tool):
|
||||
"""Test that function missing required transformed parameters raises ValueError."""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue