TDD: Add test for TypeError in infer_resource_slots() with null properties #10743

Merged
HAL9000 merged 2 commits from tdd/mcp-infer-resource-slots-null-properties into master 2026-04-27 02:40:12 +00:00
3 changed files with 78 additions and 0 deletions
+6
View File
@@ -16,6 +16,12 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
### Added
- **TDD: MCPToolAdapter.infer_resource_slots() TypeError with null properties** (#10470):
Added a TDD issue-capture Behave scenario that reproduces the bug where
`MCPToolAdapter.infer_resource_slots()` raises `TypeError` when the input schema
contains `{"properties": None}`. The test is tagged `@tdd_expected_fail` and will
pass (by inversion) until the underlying bug is fixed.
- **Architecture Pool Supervisor Milestone Assignment** (#7521): Added a "PR Workflow
for Major Changes" section to the `architecture-pool-supervisor` agent definition
documenting the milestone assignment step for spec PRs. The agent now has
@@ -0,0 +1,60 @@
"""Step definitions for features/tdd_mcp_infer_resource_slots_null_properties.feature.
TDD issue-capture scenario for #10470: MCPToolAdapter.infer_resource_slots()
raises TypeError when the input schema has a null "properties" value.
The bug: input_schema.get("properties", {}) returns None (not {}) when the
key exists with a null value, causing TypeError on iteration.
"""
from __future__ import annotations
from behave import given, then, when
from behave.runner import Context
from cleveragents.mcp.adapter import MCPToolAdapter
@given("an MCP tool input schema where properties key is null")
def step_given_null_properties_schema(context: Context) -> None:
"""Set up an input schema where 'properties' key exists but has a null value."""
context.mcp_tool_name = "test_tool"
context.mcp_input_schema = {"properties": None}
context.infer_type_error = None
context.inferred_slots_result = None
@when("I call infer_resource_slots with the null properties schema")
def step_when_infer_slots_null_properties(context: Context) -> None:
"""Call infer_resource_slots() and capture any TypeError raised."""
try:
context.inferred_slots_result = MCPToolAdapter.infer_resource_slots(
context.mcp_tool_name,
context.mcp_input_schema,
)
except TypeError as exc:
context.infer_type_error = exc
@then("no TypeError should have been raised during slot inference")
def step_then_no_type_error(context: Context) -> None:
"""Assert that no TypeError was raised during infer_resource_slots()."""
assert context.infer_type_error is None, (
f"Expected no TypeError, but got: {context.infer_type_error!r}\n"
"Bug: infer_resource_slots() raises TypeError when 'properties' is None. "
"Fix: use `input_schema.get('properties') or {}` instead of "
"`input_schema.get('properties', {})`."
)
@then("the inferred slots result should be an empty list")
def step_then_slots_empty_list(context: Context) -> None:
"""Assert that the result of infer_resource_slots() is an empty list."""
result = context.inferred_slots_result
assert result is not None, (
"inferred_slots_result is None — infer_resource_slots() likely raised "
"an exception before returning."
)
assert result == [], (
f"Expected infer_resource_slots() to return [], got: {result!r}"
)
@@ -0,0 +1,12 @@
@tdd_issue @tdd_issue_10470
Feature: TDD Issue #10470 — MCPToolAdapter.infer_resource_slots() raises TypeError when properties is null
MCPToolAdapter.infer_resource_slots() uses input_schema.get("properties", {}) to retrieve
the properties dict. When the key exists but has a null value ({"properties": None}),
dict.get() returns None instead of the default {}, causing a TypeError when iterating.
@tdd_expected_fail
Outdated
Review

Suggestion: The @tdd_issue and @tdd_issue_10470 tags are already applied at the feature level; consider removing them from the scenario header to avoid duplication.


Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker

Suggestion: The @tdd_issue and @tdd_issue_10470 tags are already applied at the feature level; consider removing them from the scenario header to avoid duplication. --- Automated by CleverAgents Bot Supervisor: PR Review | Agent: pr-review-worker
Scenario: infer_resource_slots() with null properties does not raise TypeError
Given an MCP tool input schema where properties key is null
When I call infer_resource_slots with the null properties schema
Then no TypeError should have been raised during slot inference
And the inferred slots result should be an empty list