Skip to content

Delete stale restart_required issues on startup - #5533

Open
amasolov wants to merge 1 commit into
hacs:mainfrom
amasolov:delete-stale-restart-issues
Open

amasolov wants to merge 1 commit into
hacs:mainfrom
amasolov:delete-stale-restart-issues

Conversation

@amasolov

Copy link
Copy Markdown

Summary

restart_required repair issues are created in HacsIntegrationRepository.async_post_installation, but nothing ever deletes them. The issue id embeds the ref (restart_required_{id}_{ref}), so every download mints a new id rather than reusing an existing one, and the entries accumulate in .storage/repairs.issue_registry indefinitely.

This adds a sweep in startup_tasks. Reaching that point means Home Assistant has restarted, so any restart_required issue from a previous run is by definition already resolved.

Why this is not visible today

These issues are not persistent, so core keeps them across a restart as inactive entries with their fields stripped (IssueRegistry._async_load sets active=False, and IssueEntry.to_json writes the stripped row back). That is intended core behaviour, so the fix belongs here rather than in core.

The effect is that the rows never appear in the repairs UI or the websocket API, yet they are re-serialised to storage on every save. The growth is completely silent.

On my own installation there were 122 of them, dating back 15 months:

TOTAL ROWS: 195
by domain: [('hacs', 123), ('mqtt', 61), ('template', 3), ...]
restart_required rows: 122
created min/max: 2025-06-10 .. 2026-09-09

The repairs API reported 4 issues and none of these, even including dismissed ones.

Note on #4403

#4403 also called async_delete_issue on these issues and was rejected, so I want to be explicit that this is a different change.

That PR let users dismiss a pending restart without restarting, which is the behaviour you objected to: the code is still loaded until a restart, so the warning has to stand. This PR does not add any way to dismiss anything, and does not touch the repair flow. It only deletes issues after a restart has already happened, at which point the warning has served its purpose. Behaviour before a restart is unchanged.

If the accumulation is considered acceptable, feel free to close this — but the leak is unbounded and users cannot see or clear it themselves.

Testing

  • New test test_delete_stale_restart_issues covers the deletion, that removed_* issues and other domains' issues are left alone, and that a second run is a no-op.
  • Full suite: 429 passed. tests/repositories/test_update_repository.py::test_update_repository_entity_no_update fails, but it fails identically on an unmodified checkout of adb7d83, so it is unrelated to this change.
  • ruff check, ruff format --check and isort --check-only all clean.

The restart_required repair issues are created when a downloaded
integration needs a restart to take effect, but nothing ever deletes
them. Because the issue id embeds the ref, every download creates a new
id instead of reusing an existing one, so the entries accumulate in the
issue registry indefinitely.

The issues are not persistent, so Home Assistant keeps them across a
restart as inactive entries with their fields stripped. That hides them
from the repairs UI while they are still written back to storage on
every save, so the growth is invisible. One installation had 122 of them
going back 15 months.

Reaching startup_tasks means Home Assistant has restarted, so any
restart_required issue from a previous run is already resolved and can
be deleted.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant