From 667bd627423f4edf6cd199c22d3ef778a6324e37 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 31 Mar 2026 18:09:14 +0200 Subject: [PATCH] Remove CLI command hint from unknown error messages (#6684) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove CLI command hint from unknown error messages Since #6303 introduced specific error messages for many cases, the generic "check with 'ha supervisor logs'" hint in unknown error messages is no longer as useful. Remove the CLI command part while keeping the "Check supervisor logs for details" rider. Co-Authored-By: Claude Opus 4.6 (1M context) * Use consistently "Supervisor logs" with capitalization Co-authored-by: Jan Čermák --------- Co-authored-by: Claude Opus 4.6 (1M context) Co-authored-by: Jan Čermák --- supervisor/api/utils.py | 2 +- supervisor/exceptions.py | 8 +------- supervisor/jobs/__init__.py | 4 +--- tests/api/test_addons.py | 6 ++---- tests/api/test_auth.py | 7 +++---- tests/api/test_store.py | 3 +-- tests/api/test_supervisor.py | 4 ++-- tests/jobs/test_job_manager.py | 4 ++-- 8 files changed, 13 insertions(+), 25 deletions(-) diff --git a/supervisor/api/utils.py b/supervisor/api/utils.py index ec0c0db51..e2f0ce76f 100644 --- a/supervisor/api/utils.py +++ b/supervisor/api/utils.py @@ -148,7 +148,7 @@ def api_return_error( if check_exception_chain(error, DockerAPIError): message = format_message(message) if not message: - message = "Unknown error, see Supervisor logs (check with 'ha supervisor logs')" + message = "Unknown error, see Supervisor logs" match error_type: case const.CONTENT_TYPE_TEXT: diff --git a/supervisor/exceptions.py b/supervisor/exceptions.py index fc4bef7ff..975b9a874 100644 --- a/supervisor/exceptions.py +++ b/supervisor/exceptions.py @@ -5,11 +5,6 @@ from typing import Any from .const import OBSERVER_PORT -MESSAGE_CHECK_SUPERVISOR_LOGS = ( - "Check supervisor logs for details (check with '{logs_command}')" -) -EXTRA_FIELDS_LOGS_COMMAND = {"logs_command": "ha supervisor logs"} - class HassioError(Exception): """Root exception.""" @@ -125,9 +120,8 @@ class APIUnknownSupervisorError(APIError): ) -> None: """Initialize exception.""" self.message_template = ( - f"{self.message_template}. {MESSAGE_CHECK_SUPERVISOR_LOGS}" + f"{self.message_template}. Check Supervisor logs for details" ) - self.extra_fields = (self.extra_fields or {}) | EXTRA_FIELDS_LOGS_COMMAND super().__init__(None, logger, job_id=job_id) diff --git a/supervisor/jobs/__init__.py b/supervisor/jobs/__init__.py index 309a6a60d..5432dc214 100644 --- a/supervisor/jobs/__init__.py +++ b/supervisor/jobs/__init__.py @@ -98,9 +98,7 @@ class SupervisorJobError: """Representation of an error occurring during a supervisor job.""" type_: type[HassioError] = HassioError - message: str = ( - "Unknown error, see Supervisor logs (check with 'ha supervisor logs')" - ) + message: str = "Unknown error, see Supervisor logs" stage: str | None = None error_key: str | None = None extra_fields: dict[str, Any] | None = None diff --git a/tests/api/test_addons.py b/tests/api/test_addons.py index 086c0b9d3..d11509d74 100644 --- a/tests/api/test_addons.py +++ b/tests/api/test_addons.py @@ -599,12 +599,11 @@ async def test_addon_start_options_error( body = await resp.json() assert ( body["message"] - == "An unknown error occurred with addon local_example. Check supervisor logs for details (check with 'ha supervisor logs')" + == "An unknown error occurred with addon local_example. Check Supervisor logs for details" ) assert body["error_key"] == "addon_unknown_error" assert body["extra_fields"] == { "addon": "local_example", - "logs_command": "ha supervisor logs", } assert "Add-on local_example can't write options" in caplog.text @@ -682,10 +681,9 @@ async def test_addon_rebuild_fails_error(api_client: TestClient, coresys: CoreSy body = await resp.json() assert ( body["message"] - == "An unknown error occurred while trying to build the image for addon local_ssh. Check supervisor logs for details (check with 'ha supervisor logs')" + == "An unknown error occurred while trying to build the image for addon local_ssh. Check Supervisor logs for details" ) assert body["error_key"] == "addon_build_failed_unknown_error" assert body["extra_fields"] == { "addon": "local_ssh", - "logs_command": "ha supervisor logs", } diff --git a/tests/api/test_auth.py b/tests/api/test_auth.py index 315809e1a..132dbab54 100644 --- a/tests/api/test_auth.py +++ b/tests/api/test_auth.py @@ -182,9 +182,8 @@ async def test_list_users_ws_error( result = await resp.json() assert result == { "result": "error", - "message": "Can't request listing users on Home Assistant. Check supervisor logs for details (check with 'ha supervisor logs')", + "message": "Can't request listing users on Home Assistant. Check Supervisor logs for details", "error_key": "auth_list_users_error", - "extra_fields": {"logs_command": "ha supervisor logs"}, } assert "Can't request listing users on Home Assistant: fail" in caplog.text @@ -374,7 +373,7 @@ async def test_auth_backend_login_failure(api_client: TestClient): body = await resp.json() assert ( body["message"] - == "Unable to validate authentication details with Home Assistant. Check supervisor logs for details (check with 'ha supervisor logs')" + == "Unable to validate authentication details with Home Assistant. Check Supervisor logs for details" ) assert body["error_key"] == "auth_home_assistant_api_validation_error" - assert body["extra_fields"] == {"logs_command": "ha supervisor logs"} + assert "extra_fields" not in body diff --git a/tests/api/test_store.py b/tests/api/test_store.py index bf084cbaa..ecf640271 100644 --- a/tests/api/test_store.py +++ b/tests/api/test_store.py @@ -195,11 +195,10 @@ async def test_api_store_repair_repository_git_error( assert result["error_key"] == "store_repository_unknown_error" assert result["extra_fields"] == { "repo": test_repository.slug, - "logs_command": "ha supervisor logs", } assert ( result["message"] - == f"An unknown error occurred with addon repository {test_repository.slug}. Check supervisor logs for details (check with 'ha supervisor logs')" + == f"An unknown error occurred with addon repository {test_repository.slug}. Check Supervisor logs for details" ) diff --git a/tests/api/test_supervisor.py b/tests/api/test_supervisor.py index e16a218b9..86fe4e1e6 100644 --- a/tests/api/test_supervisor.py +++ b/tests/api/test_supervisor.py @@ -443,10 +443,10 @@ async def test_supervisor_api_stats_failure( body = await resp.json() assert ( body["message"] - == "An unknown error occurred with Supervisor. Check supervisor logs for details (check with 'ha supervisor logs')" + == "An unknown error occurred with Supervisor. Check Supervisor logs for details" ) assert body["error_key"] == "supervisor_unknown_error" - assert body["extra_fields"] == {"logs_command": "ha supervisor logs"} + assert "extra_fields" not in body assert ( "Could not inspect container 'hassio_supervisor': [500] {'message': 'fail'}" in caplog.text diff --git a/tests/jobs/test_job_manager.py b/tests/jobs/test_job_manager.py index be3e91d28..44337d2c8 100644 --- a/tests/jobs/test_job_manager.py +++ b/tests/jobs/test_job_manager.py @@ -198,7 +198,7 @@ async def test_notify_on_change(coresys: CoreSys, ha_ws_client: AsyncMock): "errors": [ { "type": "HassioError", - "message": "Unknown error, see Supervisor logs (check with 'ha supervisor logs')", + "message": "Unknown error, see Supervisor logs", "stage": "test", "error_key": None, "extra_fields": None, @@ -228,7 +228,7 @@ async def test_notify_on_change(coresys: CoreSys, ha_ws_client: AsyncMock): "errors": [ { "type": "HassioError", - "message": "Unknown error, see Supervisor logs (check with 'ha supervisor logs')", + "message": "Unknown error, see Supervisor logs", "stage": "test", "error_key": None, "extra_fields": None,