From 323a5d421253a13d23eaed6920228056908fe058 Mon Sep 17 00:00:00 2001 From: CleverThis Date: Sun, 19 Apr 2026 09:57:22 +0000 Subject: [PATCH 1/2] TDD: Add test for TypeError in infer_resource_slots() with null properties Added a new Behave BDD feature file: - features/tdd_mcp_infer_resource_slots_null_properties.feature, containing a TDD scenario tagged @tdd_issue @tdd_issue_10470 @tdd_expected_fail that demonstrates the bug where MCPToolAdapter.infer_resource_slots() raises TypeError when the input schema has {"properties": None}. Added features/steps/tdd_mcp_infer_resource_slots_null_properties_steps.py: - Step definitions for the feature file. ISSUES CLOSED: #10470 --- ...er_resource_slots_null_properties_steps.py | 60 +++++++++++++++++++ ...fer_resource_slots_null_properties.feature | 12 ++++ 2 files changed, 72 insertions(+) create mode 100644 features/steps/tdd_mcp_infer_resource_slots_null_properties_steps.py create mode 100644 features/tdd_mcp_infer_resource_slots_null_properties.feature diff --git a/features/steps/tdd_mcp_infer_resource_slots_null_properties_steps.py b/features/steps/tdd_mcp_infer_resource_slots_null_properties_steps.py new file mode 100644 index 000000000..acf79a14e --- /dev/null +++ b/features/steps/tdd_mcp_infer_resource_slots_null_properties_steps.py @@ -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}" + ) diff --git a/features/tdd_mcp_infer_resource_slots_null_properties.feature b/features/tdd_mcp_infer_resource_slots_null_properties.feature new file mode 100644 index 000000000..d339476ce --- /dev/null +++ b/features/tdd_mcp_infer_resource_slots_null_properties.feature @@ -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_issue @tdd_issue_10470 @tdd_expected_fail + 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 -- 2.52.0 From 69a8bcf7ea99de4eba2b03aca84ea9239e8d5157 Mon Sep 17 00:00:00 2001 From: HAL9000 Date: Fri, 24 Apr 2026 14:01:08 +0000 Subject: [PATCH 2/2] TDD: Add test for TypeError in infer_resource_slots() with null properties --- CHANGELOG.md | 6 ++++++ .../tdd_mcp_infer_resource_slots_null_properties.feature | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5633cc4d..174e421d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/features/tdd_mcp_infer_resource_slots_null_properties.feature b/features/tdd_mcp_infer_resource_slots_null_properties.feature index d339476ce..40d22bef4 100644 --- a/features/tdd_mcp_infer_resource_slots_null_properties.feature +++ b/features/tdd_mcp_infer_resource_slots_null_properties.feature @@ -4,7 +4,7 @@ Feature: TDD Issue #10470 — MCPToolAdapter.infer_resource_slots() raises TypeE 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_issue @tdd_issue_10470 @tdd_expected_fail + @tdd_expected_fail 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 -- 2.52.0