1 Commits
Author SHA1 Message Date
Mike Degatano 0e7c4175c5 Block start/restart/rebuild/update APIs while Supervisor is not fully running (#7194)
* Block start/restart/rebuild/update APIs while Supervisor is not fully running

Supervisor boots apps and Home Assistant Core in a specific order, and
replays a similarly ordered sequence while restoring a backup (during
which it is in the freeze state). Calling start/restart/rebuild/update
via the API while one of those sequences is still in progress risks
running it out of order, or blocking a scheduled start from that
sequence outright via job concurrency.

Add a require_running_system decorator that rejects these API calls
unless Supervisor is fully started (CoreState.RUNNING), and apply it to:
- App start/restart/rebuild (fixes #7189) and update
- Home Assistant Core start/restart/rebuild/update
- Plugin (audio/dns/multicast) restart/update, and cli/observer update

Also add a translatable APISystemNotReadyError so the API returns a
clean, user-facing message and error_key instead of leaking the
technical JobConditionException message.

* Address review: neutral error wording + require_running_system test coverage

- Reword APISystemNotReadyError so it no longer implies the block is only
  due to startup, since the same guard also applies while frozen for a
  backup restore.
- Add tests/api/test_require_running_system.py covering the rejection path
  (400 + system_not_ready_error, business logic not invoked) for app
  start/restart/rebuild, app update via the store API, Core
  start/restart/rebuild/update, and all plugin update/restart routes,
  parametrized across SETUP/STARTUP/FREEZE.

* Simplify APISystemNotReadyError message wording

* Switch status code to 503
2026-09-15 14:45:26 +02:00