Skip to content

Commit 9c301d7

Browse files
Patch76claude
andcommitted
fix(tools_integrations): adopt three Gemini findings on PR #1424
F1 + F2: drop redundant logger.error calls in _delete_direct_entry's HomeAssistantAPIError-non-404 branch and Exception fallback branch. exception_to_structured_error emits a structured ToolError carrying the right ErrorCode + message but deliberately does NOT log at ERROR for classified failures — by design in helpers.py (only ErrorCode.INTERNAL_ERROR triggers logger.exception there, to avoid duplicate ERROR-log noise on classified failures). The local logger.error therefore duplicated the information surface that the structured ToolError already carries and went against the design intent. F3: add entry_id, entity_ids, require_restart keys to Path 4 (config subentry) idempotent return shape so it matches the schema used by the Path 1/2/3 idempotent returns. Callers that branch on these fields (e.g. to determine whether HA needs a restart, or to enumerate removed entity_ids) now see a consistent contract across all four idempotent branches. Net change: -2 / +3 lines in src/ha_mcp/tools/tools_integrations.py. 74 unit tests pass unchanged across test_tools_integrations.py (52) + test_config_subentries_folded.py (22). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3cb4fd7 commit 9c301d7

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/ha_mcp/tools/tools_integrations.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,6 @@ async def _delete_direct_entry(self, entry_id: str) -> dict[str, Any]:
13831383
"message": (f"Config entry {entry_id} was already absent."),
13841384
"fallback_used": "already_deleted",
13851385
}
1386-
logger.error(f"Failed to delete config entry: {e}")
13871386
exception_to_structured_error(
13881387
e,
13891388
context={"entry_id": entry_id},
@@ -1393,7 +1392,6 @@ async def _delete_direct_entry(self, entry_id: str) -> dict[str, Any]:
13931392
],
13941393
)
13951394
except Exception as e:
1396-
logger.error(f"Failed to delete config entry: {e}")
13971395
exception_to_structured_error(
13981396
e,
13991397
context={"entry_id": entry_id},
@@ -1658,6 +1656,9 @@ async def _delete_config_subentry(
16581656
"helper_type": "config_subentry",
16591657
"subentry_id": subentry_id,
16601658
"method": "config_subentry_delete",
1659+
"entry_id": entry_id,
1660+
"entity_ids": [],
1661+
"require_restart": False,
16611662
"message": (
16621663
f"Subentry {subentry_id} was already absent from "
16631664
f"config entry {entry_id}."

0 commit comments

Comments
 (0)