Skip to content

Commit 91d99ef

Browse files
committed
Merge remote-tracking branch 'origin/master' into agent/add-klingon-language
2 parents 34ef853 + af7a4d0 commit 91d99ef

3 files changed

Lines changed: 35 additions & 12 deletions

File tree

homeassistant-addon-dev/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: "Home Assistant MCP Server (Dev)"
22
description: "Development channel - AI assistant integration via MCP (unstable)"
3-
version: "8.3.0.dev2433"
3+
version: "8.3.0.dev2436"
44
slug: "ha_mcp_dev"
55
url: "https://github.com/homeassistant-ai/ha-mcp"
66
stage: experimental

src/ha_mcp/client/rest_client.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -823,18 +823,20 @@ async def _supervisor_logs_get(self, path: str, lines: int | None = None) -> str
823823
)
824824

825825
try:
826-
async with make_supervisor_httpx_client(
827-
timeout=httpx.Timeout(self.timeout),
828-
verify=self.verify_ssl,
829-
) as client:
830-
response = await client.get(
831-
relative_path,
832-
headers={"Accept": "text/plain"},
833-
params={"lines": lines} if lines is not None else None,
834-
)
835-
except httpx.TimeoutException as e:
826+
async with asyncio.timeout(self.timeout):
827+
async with make_supervisor_httpx_client(
828+
timeout=httpx.Timeout(self.timeout),
829+
verify=self.verify_ssl,
830+
) as client:
831+
response = await client.get(
832+
relative_path,
833+
headers={"Accept": "text/plain"},
834+
params={"lines": lines} if lines is not None else None,
835+
)
836+
except (TimeoutError, httpx.TimeoutException) as e:
836837
raise HomeAssistantConnectionError(
837-
f"Timeout fetching /{path}/logs from Supervisor: {e}"
838+
f"Timeout fetching /{path}/logs from Supervisor after "
839+
f"{self.timeout}s: {str(e) or type(e).__name__}"
838840
) from e
839841
except httpx.HTTPError as e:
840842
raise HomeAssistantConnectionError(

tests/src/unit/test_tools_utility_supervisor_logs.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
error translation.
1818
"""
1919

20+
import asyncio
2021
import json
2122
import re
2223
from pathlib import Path
@@ -435,6 +436,26 @@ async def test_raises_connection_error_on_timeout_with_distinct_message(
435436

436437
assert "Timeout" in str(exc_info.value)
437438

439+
@pytest.mark.asyncio
440+
@pytest.mark.timeout(10)
441+
async def test_supervisor_log_fetch_has_overall_deadline(
442+
self, mock_client, addon_install, mock_async_client_class
443+
):
444+
"""A stalled Supervisor log body must not wait forever on per-chunk IO."""
445+
inner_client, _ = mock_async_client_class
446+
mock_client.timeout = 0.01
447+
448+
async def _hang_forever(*_args, **_kwargs):
449+
"""Model a Supervisor response that never completes."""
450+
await asyncio.Event().wait()
451+
452+
inner_client.get.side_effect = _hang_forever
453+
454+
with pytest.raises(HomeAssistantConnectionError) as exc_info:
455+
await mock_client.get_addon_logs("core_mosquitto")
456+
457+
assert "after 0.01s: TimeoutError" in str(exc_info.value)
458+
438459
@pytest.mark.asyncio
439460
async def test_raises_connection_error_on_network_failure_with_distinct_message(
440461
self, mock_client, addon_install, mock_async_client_class

0 commit comments

Comments
 (0)