Repository navigation
Conversation
The admin dashboard used to rewrite config.toml in place when an admin turned protocol auth or new connections on or off. That write was not atomic, failed for read-only config files, and was undone on every restart of the Home Assistant add-on, which regenerates config.toml from its options. Dashboard changes are now stored atomically in state/admin_settings.json. The config file provides the default, and a stored value is discarded once the config value it overrode changes, so the most recent change wins. An invalid settings file stops the server with a clear error instead of silently reopening access.
Also describe the precedence rule of stored dashboard settings precisely.
Without syncing the directory, a power failure right after a change could bring back the previous file and silently undo a restriction.
The shipped compose.yaml mounts config.toml read-only, which made the toggles fail with HTTP 500 before the settings moved to the state directory.
1 of 2 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #196.
When an admin turns Protocol auth or New connections on or off in the dashboard, the server used to rewrite
config.tomlin place. That causes three problems:compose.yamlmountsconfig.tomlread-only, so the toggle returns HTTP 500 with[Errno 30] Read-only file system: '/app/config.toml'and the setting does not change.config.tomlfrom its options on every start, and always writes both settings astrue. Turning off new connections in the dashboard was therefore undone by the next add-on restart.config.toml.Dashboard changes are now stored in
state/admin_settings.jsonin the data directory, andconfig.tomlis never written by the server.Existing installs need no migration. Their current config values remain the defaults. This also covers configs generated on every start, such as the environment-variable config proposed in #176.
Before you open this PR (optional, but very helpful)
[Errno 30] Read-only file system: '/app/config.toml'on the shipped compose.yaml #196 reports this bug. Add a browser setup wizard, env-var config and a redesigned admin dashboard #176 touches the same files but does not change how the toggles are stored.PRs I reviewed:
Proof that it works
Tested on:
What I did and what happened:
New tests:
tests/test_admin_api.py:config.tomland its directory are read-only, as with the:romount incompose.yaml. The config stays byte-for-byte unchanged and both changes survive a restart. Without this fix, the same test fails with HTTP 500.config.tomlis left unchanged. This replaces the two tests of the old in-place rewrite.tests/test_admin_settings.py:tests/test_ha_addon.py: both toggles survive the add-on regeneratingconfig.tomlfrom its options.uv run pytest -qpasses in full.Screenshots (required for any UI change)
No UI changes. The dashboard behaves the same, except that the toggles now work with the shipped
compose.yamland survive restarts of the Home Assistant add-on.