Commit 97faac5
* fix: Signal tool errors via isError for automation, service, and registry tools (#518)
Part 1 of the isError signaling fix. Adds core infrastructure and applies
to tools that already have comprehensive E2E test coverage.
Core changes:
- Add raise_tool_error() helper to convert error dicts to ToolError exceptions
- Update exception_to_structured_error() to raise by default (raise_error=True)
- Add @overload type signatures for raise_error parameter
- Add safe_call_tool() and tool_error_to_result() test utilities
Tool changes (3 tools with existing E2E tests):
- tools_config_automations: 5 error paths now raise ToolError
- tools_service: 4 error paths now raise ToolError
- tools_registry: 1 error path now raises ToolError
Test updates:
- Update 11 E2E test files to use safe_call_tool for error path testing
- Add unit tests for raise_tool_error and exception_to_structured_error
- Add retry logic for entity rename tests (timing robustness)
Closes part of #518
https://claude.ai/code/session_01MvDDV6qmWosBfGhmTLYzo8
* refactor: use match statement and keep raise_error=False as default
Per code review feedback:
1. Use match statement for HTTP status code dispatch (Python 3.13)
2. Keep raise_error=False as default to avoid regression during PR stack
- Tools explicitly pass raise_error=True or use raise_error=False + raise_tool_error()
- Part 5 will flip the default after all tools are migrated
3. Update unit tests to reflect new default behavior
https://claude.ai/code/session_01MvDDV6qmWosBfGhmTLYzo8
* fix: Address code review feedback on PR #551
Fixes for HIGH priority issues:
- H1: Add `except ToolError: raise` before `except Exception` handlers in
tools_config_automations.py and tools_service.py to prevent double-wrapping
- H2: Change return type annotation to `dict[str, Any]` (NoReturn in union is meaningless)
- H3: Add case 403 to match statement for auth/permission errors
Fixes for MEDIUM priority issues:
- M2: Add `default=str` to json.dumps in raise_tool_error for non-serializable fallback
- M3: Change pytest.skip to pytest.xfail in test_lights.py to not mask regressions
https://claude.ai/code/session_01MvDDV6qmWosBfGhmTLYzo8
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent c847979 commit 97faac5
16 files changed
Lines changed: 705 additions & 255 deletions
File tree
- src/ha_mcp/tools
- tests/src
- e2e
- utilities
- workflows
- automation
- blueprints
- calendar
- core
- device_control
- registry
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
32 | 63 | | |
33 | 64 | | |
34 | 65 | | |
| |||
52 | 83 | | |
53 | 84 | | |
54 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
55 | 104 | | |
56 | 105 | | |
57 | 106 | | |
| 107 | + | |
| 108 | + | |
58 | 109 | | |
59 | 110 | | |
60 | 111 | | |
| |||
65 | 116 | | |
66 | 117 | | |
67 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
68 | 125 | | |
69 | 126 | | |
70 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
71 | 131 | | |
72 | 132 | | |
73 | 133 | | |
74 | 134 | | |
| 135 | + | |
| 136 | + | |
75 | 137 | | |
76 | 138 | | |
77 | 139 | | |
78 | | - | |
79 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
80 | 143 | | |
81 | | - | |
| 144 | + | |
82 | 145 | | |
83 | | - | |
84 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
85 | 149 | | |
86 | | - | |
| 150 | + | |
87 | 151 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
109 | 175 | | |
110 | | - | |
| 176 | + | |
111 | 177 | | |
112 | 178 | | |
113 | | - | |
| 179 | + | |
114 | 180 | | |
115 | | - | |
116 | | - | |
| 181 | + | |
| 182 | + | |
117 | 183 | | |
118 | 184 | | |
119 | | - | |
| 185 | + | |
120 | 186 | | |
121 | 187 | | |
122 | | - | |
123 | | - | |
124 | | - | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
125 | 209 | | |
| 210 | + | |
126 | 211 | | |
127 | 212 | | |
128 | 213 | | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
| 214 | + | |
| 215 | + | |
137 | 216 | | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
| 217 | + | |
145 | 218 | | |
146 | 219 | | |
147 | 220 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | | - | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
249 | 250 | | |
250 | 251 | | |
251 | 252 | | |
252 | | - | |
| 253 | + | |
253 | 254 | | |
254 | 255 | | |
255 | 256 | | |
256 | 257 | | |
257 | 258 | | |
| 259 | + | |
258 | 260 | | |
259 | 261 | | |
260 | 262 | | |
| |||
263 | 265 | | |
264 | 266 | | |
265 | 267 | | |
266 | | - | |
| 268 | + | |
267 | 269 | | |
268 | 270 | | |
269 | 271 | | |
| |||
411 | 413 | | |
412 | 414 | | |
413 | 415 | | |
414 | | - | |
| 416 | + | |
415 | 417 | | |
416 | 418 | | |
417 | 419 | | |
418 | | - | |
| 420 | + | |
419 | 421 | | |
420 | 422 | | |
421 | 423 | | |
422 | | - | |
| 424 | + | |
423 | 425 | | |
424 | 426 | | |
425 | 427 | | |
426 | | - | |
| 428 | + | |
427 | 429 | | |
428 | 430 | | |
429 | 431 | | |
| |||
441 | 443 | | |
442 | 444 | | |
443 | 445 | | |
444 | | - | |
| 446 | + | |
445 | 447 | | |
446 | 448 | | |
447 | 449 | | |
448 | | - | |
| 450 | + | |
449 | 451 | | |
450 | 452 | | |
451 | 453 | | |
| |||
454 | 456 | | |
455 | 457 | | |
456 | 458 | | |
| 459 | + | |
| 460 | + | |
457 | 461 | | |
458 | 462 | | |
459 | 463 | | |
460 | 464 | | |
461 | 465 | | |
| 466 | + | |
462 | 467 | | |
463 | 468 | | |
464 | 469 | | |
| |||
469 | 474 | | |
470 | 475 | | |
471 | 476 | | |
472 | | - | |
| 477 | + | |
473 | 478 | | |
474 | 479 | | |
475 | 480 | | |
| |||
513 | 518 | | |
514 | 519 | | |
515 | 520 | | |
| 521 | + | |
516 | 522 | | |
517 | 523 | | |
518 | 524 | | |
| |||
522 | 528 | | |
523 | 529 | | |
524 | 530 | | |
525 | | - | |
| 531 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
785 | 785 | | |
786 | 786 | | |
787 | 787 | | |
788 | | - | |
| 788 | + | |
789 | 789 | | |
790 | 790 | | |
791 | | - | |
| 791 | + | |
792 | 792 | | |
793 | 793 | | |
794 | 794 | | |
| |||
0 commit comments