Commit 8e96914
committed
refactor: address PR #1397 KP13 second-pass review (D4 available_*_ids parity)
Extend the #1297 RESOURCE_NOT_FOUND classifier audit to the three remaining
sites flagged in KP13's second-pass review — same audit family as the labels /
categories / zones / devices sibling sites already covered in this PR:
- ``ha_config_delete_dashboard`` (tools_config_dashboards.py): reuse the
dashboard list returned by ``_resolve_dashboard`` (previously discarded
via ``_``) and splice first-10 ``url_path`` entries into
``available_dashboard_ids``.
- ``_get_automation_config_internal`` (tools_config_automations.py): new
central not-found raise — catches ``HomeAssistantAPIError(status_code=404)``
from the REST client and emits ``RESOURCE_NOT_FOUND`` with
``available_automation_ids`` sourced from a best-effort
``config/entity_registry/list`` filtered by ``automation.`` prefix.
Other ``HomeAssistantAPIError`` instances propagate unchanged.
- ``_fetch_script_config_envelope`` (tools_config_scripts.py): new private
helper mirroring the automations shape, used by both ``ha_config_get_script``
and ``_get_script_config_internal`` to centralize the 404→RESOURCE_NOT_FOUND
translation. ``available_script_ids`` populated the same way.
Both list-fetch helpers (``_list_automation_entity_ids`` /
``_list_script_entity_ids``) are best-effort: a registry-list failure
yields an empty list rather than masking the 404 behind a registry error.
5 new regression tests in ``tests/src/unit/test_error_code_consistency_1297.py``
pin the new shape at sibling depth — error code + list-tool suggestion +
``available_*_ids`` payload, plus the empty-list-on-registry-failure
fallback for the automations and scripts paths.1 parent 466ce2c commit 8e96914
4 files changed
Lines changed: 357 additions & 5 deletions
File tree
- src/ha_mcp/tools
- tests/src/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
838 | 839 | | |
839 | 840 | | |
840 | 841 | | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
841 | 870 | | |
842 | 871 | | |
843 | 872 | | |
844 | 873 | | |
845 | 874 | | |
846 | 875 | | |
847 | 876 | | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
848 | 883 | | |
849 | | - | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
850 | 904 | | |
851 | 905 | | |
852 | 906 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1530 | 1530 | | |
1531 | 1531 | | |
1532 | 1532 | | |
1533 | | - | |
| 1533 | + | |
1534 | 1534 | | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
1535 | 1540 | | |
1536 | 1541 | | |
1537 | 1542 | | |
| |||
1541 | 1546 | | |
1542 | 1547 | | |
1543 | 1548 | | |
1544 | | - | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
1545 | 1554 | | |
1546 | 1555 | | |
1547 | 1556 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
122 | 123 | | |
123 | 124 | | |
124 | 125 | | |
125 | | - | |
| 126 | + | |
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
| |||
170 | 171 | | |
171 | 172 | | |
172 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
173 | 233 | | |
174 | 234 | | |
175 | 235 | | |
| |||
178 | 238 | | |
179 | 239 | | |
180 | 240 | | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
181 | 244 | | |
182 | | - | |
| 245 | + | |
183 | 246 | | |
184 | 247 | | |
185 | 248 | | |
| |||
0 commit comments