Skip to content

Commit 7f7a53b

Browse files
kingpanther13claude
andcommitted
fix: CI ruff lint and E2E voice assistant proxy error propagation
- Let ToolError propagate through proxy instead of wrapping it, so FastMCP handles isError flag correctly (fixes voice assistant test) - Remove trailing whitespace on blank lines in test_traces.py (W293) - Fix Yoda condition in test_tool_proxy.py (SIM300) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 84ad018 commit 7f7a53b

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/ha_mcp/tools/tool_proxy.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import typing
2121
from typing import Annotated, Any
2222

23+
from fastmcp.exceptions import ToolError
2324
from pydantic import Field
2425

2526
from ..errors import (
@@ -573,6 +574,8 @@ async def ha_execute_tool(
573574
result = await implementation(**parsed_args)
574575
return result
575576

577+
except ToolError:
578+
raise # Let ToolErrors propagate — FastMCP handles isError flag
576579
except TypeError as e:
577580
return create_validation_error(
578581
message=f"Parameter error: {e}",

tests/src/e2e/workflows/automation/test_traces.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,18 +170,18 @@ async def check_automation_traces():
170170

171171
assert detailed_data.get("success") is True
172172
assert detailed_data.get("run_id") == run_id
173-
173+
174174
# Verify detailed content structure (Deep verification)
175175
# This ensures we correctly parsed the flat structure (trigger/0, action/0)
176176
assert "trigger" in detailed_data, "Detailed trace should contain trigger info"
177177
assert "action_trace" in detailed_data, "Detailed trace should contain action_trace"
178178
assert isinstance(detailed_data["action_trace"], list), "action_trace should be a list"
179179
assert len(detailed_data["action_trace"]) > 0, "action_trace should not be empty"
180-
180+
181181
# Check for path property to ensure flat structure parsing worked
182182
first_action = detailed_data["action_trace"][0]
183183
assert "path" in first_action, "Action trace element should contain 'path'"
184-
184+
185185
logger.info(f"Detailed trace verified: Found {len(detailed_data['action_trace'])} actions")
186186

187187
async def test_empty_traces_with_diagnostics(

tests/src/unit/test_tool_proxy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,5 +219,5 @@ class TestProxyModulesConfig:
219219
def test_expected_modules(self):
220220
expected = {"tools_zones", "tools_labels", "tools_addons",
221221
"tools_voice_assistant", "tools_traces"}
222-
assert PROXY_MODULES == expected
222+
assert expected == PROXY_MODULES
223223
assert all(m.startswith("tools_") for m in PROXY_MODULES)

0 commit comments

Comments
 (0)