Skip to content

Commit 7a0ccad

Browse files
kingpanther13claude
andcommitted
fix: bound error_log fetches with paginated journald windows (#2279)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AgVydTVw2uzQqdnxZ7jfJv
1 parent f2fc5f9 commit 7a0ccad

17 files changed

Lines changed: 2883 additions & 1481 deletions

site/src/data/tools.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2100,7 +2100,7 @@
21002100
{
21012101
"name": "ha_get_logs",
21022102
"title": "Get Logs",
2103-
"description": "Get Home Assistant logs from various sources.\n\n**Sources:**\n- \"logbook\" (default): Entity state change history with pagination\n- \"system\": Structured system log entries (errors, warnings) via system_log/list\n- \"error_log\": Raw log text (home-assistant.log on container/pip installs; HA Core's journald stream on Supervisor-backed installs)\n- \"supervisor\": Add-on container logs (requires slug = add-on slug)\n- \"system_service\": HA-Supervisor-managed system service logs (requires\n slug ∈ {supervisor, host, core, dns, audio, cli, multicast, observer})\n- \"logger\": Effective log level per integration via logger/log_info (confirms logger.set_level changes took effect)\n\n**Prefer source='system' for triage.** It returns HA's own deduplicated\nsystem_log entries with counts, first_occurred and full tracebacks; of\nthose only the tracebacks are unrecoverable from the structured\nerror_log summary — they are present in the raw text, so structured=False\ngets them back. Its counts also run\nsince each error first occurred, while structured error_log counts only\nwhat is inside the fetched window (reported as window_start/window_end;\nSupervisor-backed installs read a capped journald slice). Use error_log\nwith structured=True for entries below system_log's WARNING+ ~50-entry\ncap, or for the per-component rollup.\n\n**Shared params:** limit, search (keyword filter on entries/lines; matches integration domain for source='logger')\n**Order:** order='newest' (default) returns most-recent first; order='oldest' returns chronological-first. Applies to all time-ordered sources (logbook, system, error_log, supervisor, system_service); ignored for source='logger' and for error_log with structured=True. For raw-text sources (error_log, supervisor, system_service) it sets the read direction of the most-recent window.\n**Logbook params:** hours_back, entity_id, end_time, offset, compact (default True — strips attribute dicts to save context)\n**System/error_log params:** level (ERROR, WARNING, INFO, DEBUG, CRITICAL)\n**error_log params:** structured, top_n. In structured mode `search`\n matches the message and logger name only, whereas on the raw path it\n matches the whole line; `limit`/`order` do not apply, and issues are\n ranked by count, then severity, then recency.\n**Supervisor params:** slug = add-on slug, e.g. \"core_mosquitto\" (use\n ha_get_app() to list installed slugs)\n**System-service params:** slug = service name. The slug \"supervisor\"\n here means the Supervisor service's own logs, NOT an add-on with\n that name — the source param disambiguates.",
2103+
"description": "Get Home Assistant logs from various sources.\n\n**Sources:**\n- \"logbook\" (default): Entity state change history with pagination\n- \"system\": Structured system log entries (errors, warnings) via system_log/list\n- \"error_log\": Raw log text (home-assistant.log on container/pip installs; HA Core's journald stream on Supervisor-backed installs)\n- \"supervisor\": Add-on container logs (requires slug = add-on slug)\n- \"system_service\": HA-Supervisor-managed system service logs (requires\n slug ∈ {supervisor, host, core, dns, audio, cli, multicast, observer})\n- \"logger\": Effective log level per integration via logger/log_info (confirms logger.set_level changes took effect)\n\n**Prefer source='system' for triage.** It returns HA's own deduplicated\nsystem_log entries with counts, first_occurred and full tracebacks; of\nthose only the tracebacks are unrecoverable from the structured\nerror_log summary — they are present in the raw text, so structured=False\ngets them back. Its counts also run\nsince each error first occurred, while structured error_log counts only\nwhat is inside the fetched window (reported as window_start/window_end;\nevery install now reads a capped window). Use error_log\nwith structured=True for entries below system_log's WARNING+ ~50-entry\ncap, or for the per-component rollup.\n\n**Shared params:** limit, search (keyword filter on entries/lines; matches integration domain for source='logger')\n**Order:** order='newest' (default) returns most-recent first; order='oldest' returns chronological-first. Applies to all time-ordered sources (logbook, system, error_log, supervisor, system_service); ignored for source='logger' and for error_log with structured=True. For raw-text sources (error_log, supervisor, system_service) it sets the read direction of the most-recent window.\n**Logbook params:** hours_back, entity_id, end_time, compact (default True — strips attribute dicts to save context)\n**Pagination (logbook + error_log):** offset pages deeper; ignored for the\n other sources. Logbook responses carry has_more plus a\n pagination_hint. On error_log, offset counts raw log lines back from\n the newest entry (journald entries on Supervisor-backed installs),\n both modes read a bounded window per call — so `level`/`search`\n filter and `limit` slice within that window only, and window_lines\n reports the size actually requested — and the response carries\n has_more with a next_offset to pass back while it stays true.\n**System/error_log params:** level (ERROR, WARNING, INFO, DEBUG, CRITICAL)\n**error_log params:** structured, top_n. In structured mode `search`\n matches the message and logger name only, whereas on the raw path it\n matches the whole line; `limit`/`order` do not apply, issues are\n ranked by count, then severity, then recency, and the summary covers\n a fixed deep window rather than the caller's limit.\n**Supervisor params:** slug = add-on slug, e.g. \"core_mosquitto\" (use\n ha_get_app() to list installed slugs)\n**System-service params:** slug = service name. The slug \"supervisor\"\n here means the Supervisor service's own logs, NOT an add-on with\n that name — the source param disambiguates.",
21042104
"inputSchema": {
21052105
"properties": {
21062106
"source": {
@@ -2132,7 +2132,7 @@
21322132
"default": null
21332133
},
21342134
"offset": {
2135-
"type": "Annotated[int, Field(ge=0)]",
2135+
"type": "Annotated[int, Field(ge=0, description=\"Page deeper into source='logbook' and source='error_log' (ignored for other sources). On error_log it counts raw log lines back from the newest entry; pass the response's 'next_offset' to continue while 'has_more' is true.\")]",
21362136
"default": 0
21372137
},
21382138
"compact": {
@@ -2165,7 +2165,7 @@
21652165
"tags": [
21662166
"History & Statistics"
21672167
],
2168-
"source_file": "tools_utility.py"
2168+
"source_file": "tools_logs.py"
21692169
},
21702170
{
21712171
"name": "ha_get_integration",

0 commit comments

Comments
 (0)