TDD: MCPToolAdapter.infer_resource_slots() raises TypeError when input schema has null properties #10470

Closed
opened 2026-04-18 10:00:32 +00:00 by HAL9000 · 1 comment
Owner

Metadata

  • Branch: tdd/mcp-infer-resource-slots-null-properties
  • Commit Message: TDD: Add test for TypeError in infer_resource_slots() with null properties
  • Related Bug: (to be linked after bug issue is created)

Summary

This TDD issue captures the TypeError crash in MCPToolAdapter.infer_resource_slots() when an MCP server returns a tool schema where the "properties" key exists but has a null value.

Root Cause

In src/cleveragents/mcp/adapter.py, the infer_resource_slots() method uses:

properties: dict[str, Any] = input_schema.get("properties", {})

The default value {} only applies when the key is absent. If the key exists with a null value (i.e., {"properties": null}), dict.get() returns None — not {}. The subsequent iteration:

for param_name in properties:

then raises TypeError: 'NoneType' object is not iterable.

This can be triggered by any MCP server that returns a JSON Schema with "properties": null, which is valid JSON but not a valid JSON Schema object.

Test to Write

A test tagged with @tdd_issue, @tdd_issue_<N>, and @tdd_expected_fail that:

  1. Calls MCPToolAdapter.infer_resource_slots("test_tool", {"properties": None})
  2. Asserts that no TypeError is raised
  3. Asserts that the result is an empty list []

Subtasks

  • Write a unit test calling infer_resource_slots() with {"properties": None} as input_schema
  • Tag the test with @tdd_issue, @tdd_issue_10470, and @tdd_expected_fail
  • Verify the test fails with TypeError (proving the bug exists)
  • Create tdd/mcp-infer-resource-slots-null-properties branch and open PR

Acceptance Criteria

  • Test demonstrates that infer_resource_slots("tool", {"properties": None}) raises TypeError (proving the bug)
  • Test is tagged with @tdd_issue, @tdd_issue_<N>, and @tdd_expected_fail
  • Test passes CI with @tdd_expected_fail tag (inverted result)

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.

Automated by CleverAgents Bot
Supervisor: Bug Hunt Pool | Agent: bug-hunt-pool-supervisor
Tag: [AUTO-BUG-7]


Automated by CleverAgents Bot
Agent: new-issue-creator

## Metadata - **Branch:** `tdd/mcp-infer-resource-slots-null-properties` - **Commit Message:** `TDD: Add test for TypeError in infer_resource_slots() with null properties` - **Related Bug:** (to be linked after bug issue is created) ## Summary This TDD issue captures the `TypeError` crash in `MCPToolAdapter.infer_resource_slots()` when an MCP server returns a tool schema where the `"properties"` key exists but has a `null` value. ## Root Cause In `src/cleveragents/mcp/adapter.py`, the `infer_resource_slots()` method uses: ```python properties: dict[str, Any] = input_schema.get("properties", {}) ``` The default value `{}` only applies when the key is **absent**. If the key exists with a `null` value (i.e., `{"properties": null}`), `dict.get()` returns `None` — not `{}`. The subsequent iteration: ```python for param_name in properties: ``` then raises `TypeError: 'NoneType' object is not iterable`. This can be triggered by any MCP server that returns a JSON Schema with `"properties": null`, which is valid JSON but not a valid JSON Schema object. ## Test to Write A test tagged with `@tdd_issue`, `@tdd_issue_<N>`, and `@tdd_expected_fail` that: 1. Calls `MCPToolAdapter.infer_resource_slots("test_tool", {"properties": None})` 2. Asserts that no `TypeError` is raised 3. Asserts that the result is an empty list `[]` ## Subtasks - [x] Write a unit test calling `infer_resource_slots()` with `{"properties": None}` as input_schema - [x] Tag the test with `@tdd_issue`, `@tdd_issue_10470`, and `@tdd_expected_fail` - [x] Verify the test fails with `TypeError` (proving the bug exists) - [x] Create `tdd/mcp-infer-resource-slots-null-properties` branch and open PR ## Acceptance Criteria - Test demonstrates that `infer_resource_slots("tool", {"properties": None})` raises `TypeError` (proving the bug) - Test is tagged with `@tdd_issue`, `@tdd_issue_<N>`, and `@tdd_expected_fail` - Test passes CI with `@tdd_expected_fail` tag (inverted result) ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. --- Automated by CleverAgents Bot Supervisor: Bug Hunt Pool | Agent: bug-hunt-pool-supervisor Tag: [AUTO-BUG-7] --- **Automated by CleverAgents Bot** Agent: new-issue-creator
Author
Owner

Implementation Attempt — Tier 3: Sonnet — Success

Implemented the TDD test case for issue #10470 demonstrating the TypeError bug in MCPToolAdapter.infer_resource_slots() when the input schema has {"properties": None}.

What was done:

  • Created features/tdd_mcp_infer_resource_slots_null_properties.feature with a scenario tagged @tdd_issue @tdd_issue_10470 @tdd_expected_fail
  • Created features/steps/tdd_mcp_infer_resource_slots_null_properties_steps.py with step definitions
  • The test correctly demonstrates the bug: TypeError: 'NoneType' object is not iterable is raised when iterating over None properties
  • With @tdd_expected_fail, CI treats the failing test as passing (proving the bug exists)

Quality gates: lint ✓, typecheck ✓, unit_tests ✓ (targeted test passed with @tdd_expected_fail inversion)

PR: #10743#10743


Automated by CleverAgents Bot
Supervisor: Implementation Pool | Agent: implementation-worker

**Implementation Attempt** — Tier 3: Sonnet — Success Implemented the TDD test case for issue #10470 demonstrating the `TypeError` bug in `MCPToolAdapter.infer_resource_slots()` when the input schema has `{"properties": None}`. **What was done:** - Created `features/tdd_mcp_infer_resource_slots_null_properties.feature` with a scenario tagged `@tdd_issue @tdd_issue_10470 @tdd_expected_fail` - Created `features/steps/tdd_mcp_infer_resource_slots_null_properties_steps.py` with step definitions - The test correctly demonstrates the bug: `TypeError: 'NoneType' object is not iterable` is raised when iterating over `None` properties - With `@tdd_expected_fail`, CI treats the failing test as passing (proving the bug exists) **Quality gates:** lint ✓, typecheck ✓, unit_tests ✓ (targeted test passed with @tdd_expected_fail inversion) **PR:** #10743 — https://git.cleverthis.com/cleveragents/cleveragents-core/pulls/10743 --- **Automated by CleverAgents Bot** Supervisor: Implementation Pool | Agent: implementation-worker
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#10470
No description provided.