Repository navigation
Disable Device Builder version history auto-commit by default - #169
Conversation
Device Builder auto-commits every YAML change under /config to git. It is enabled by default upstream and exposes no environment override, so where /config is a bind mount into the user's own repository the dashboard adopts that repository and commits to it unprompted. The commits are authored "ESPHome Device Builder <[email protected]>", unsigned (commit.gpgsign=false), and skip hooks (--no-verify), so a repository with branch protection requiring signed commits cannot push them at all. Detection is a polling stat-based scanner rather than inotify, so it also picks up edits made on the filesystem from outside the dashboard. The preference lives in /config/.device-builder-preferences.json. The store is RAM-canonical with a debounced write plus a shutdown flush, so patching the file while the dashboard runs is overwritten, and the image cannot ship the file because /config is a bind mount. Seed it from the entrypoint instead, before exec. The preference is enforced on every start rather than seeded once: upstream defaults it on, and the failure mode is writes to somebody else's repository, so a config that drifts back on is a real risk. Set ESPHOME_VERSION_HISTORY=true to keep the upstream behavior. Seeding is non-fatal by design; all entrypoint scripts run under set -e, and a read-only or absent /config warns and continues rather than aborting container startup. The write is an atomic replace preserving mode 0600, and a malformed existing file is left untouched. Upstream: esphome/device-builder#2193 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR prevents ESPHome Device Builder from auto-committing /config YAML edits into a user-mounted git repository by default, by seeding version_history_enabled in the preferences file at container startup (with an opt-in ESPHOME_VERSION_HISTORY=true escape hatch). It also documents the behavioral change and the rationale in the project docs.
Changes:
- Seed
/config/.device-builder-preferences.jsonfromDocker/entrypoint/dashboard.shbefore startingesphome-device-builder, defaulting version history off unless explicitly enabled viaESPHOME_VERSION_HISTORY. - Add documentation/release-note callouts in
README.mdandHISTORY.mddescribing the upstream behavior and the container’s default. - Add a reference link to the upstream issue (
device-builder#2193).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
Docker/entrypoint/dashboard.sh |
Seeds Device Builder preferences before launching the dashboard to disable version-history auto-commits by default. |
README.md |
Adds release note + warning callout and documents ESPHOME_VERSION_HISTORY. |
HISTORY.md |
Adds 1.9 release note entry documenting the default-disable behavior and links upstream issue. |
Address Copilot review on #169. The fail-open paths logged to stdout without a marker, so a seeding failure read like normal startup output. They now warn on stderr with a "Warning:" prefix and name the consequence: the preference stays at the upstream default. A failure after the temp file is written left .device-builder-preferences.json.entrypoint.tmp behind under /config, which is exactly the kind of stray artifact in the user's repository this change exists to prevent. Remove it on the failure path. The README and HISTORY wording claimed the setting is disabled unconditionally, which overstates a deliberately fail-open script. Both now say it warns and continues when /config cannot be written. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
README.md:25
- The 1.9 bullet says the version history feature is "Disabled ... stopping it from committing /config changes", but the entrypoint is intentionally fail-open when
/configis unwritable or the preferences JSON is malformed (leaving upstream default enabled). Consider wording this as "disabled by default" to avoid implying it is guaranteed in all environments.
- Disabled Device Builder's version history feature, stopping it from committing `/config` changes to git ([device-builder#2193][device-builder-version-history-link]).
Address Copilot review on #169. The bash fallback for a failed python3 invocation still went to stdout, inconsistent with the seeding script's own warnings. Send it to stderr and name the file and the consequence, matching the other fail-open paths. Reference the follow-up upstream issue alongside the original. The first filing was closed, and esphome/device-builder#2194 restates it concisely. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
README.md:25
- The release-notes bullet says the feature is disabled and "stopping" commits, but the entrypoint script is intentionally fail-open when /config cannot be written or preferences are malformed. Reword the bullet to reflect that this is a default/best-effort disablement rather than a guarantee.
- Disabled Device Builder's version history feature, stopping it from committing `/config` changes to git ([device-builder#2193][device-builder-version-history-link], [#2194][device-builder-version-history-followup-link]).
README.md:51
- This line states the default is false, but container behavior can still fall back to the upstream default if /config cannot be written (or the prefs file is malformed), as described in the warning above. Consider clarifying that the default is "false" when the entrypoint can persist the preference.
- `ESPHOME_VERSION_HISTORY` (Optional) : Enables Device Builder's git version history auto-commit, e.g. `ESPHOME_VERSION_HISTORY=true`, default is `false`.
Address Copilot review on #169. A chmod failure aborted the whole write, so a filesystem that cannot honor POSIX modes left version history at the upstream default - fail-closed on the wrong axis, since the point of the change is preventing unprompted commits, not enforcing a permission bit. Pass the mode to os.open instead. The mode becomes advisory to the filesystem rather than a separate failing step, and the file is never briefly world-readable between creation and chmod. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
README.md:25
- The release-note bullet uses the link label "[#2194]" even though it points to an upstream device-builder issue, and the wording "stopping it" reads as unconditional. Consider labeling the link as "device-builder#2194" and aligning the sentence with the documented fail-open behavior (warn and continue if /config cannot be written).
- Disabled Device Builder's version history feature, stopping it from committing `/config` changes to git ([device-builder#2193][device-builder-version-history-link], [#2194][device-builder-version-history-followup-link]).
Address Copilot review on #169. A bare [#2194] reads as a local issue number, which is how this repository labels its own ([#161], [#60]). Qualify it the same way the sibling reference already is. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
README.md:25
- The 1.9 release-note bullet reads as if version history is always disabled ("stopping it from committing"), but the entrypoint script is intentionally fail-open when
/configis read-only/missing or the preferences file is malformed. Consider softening this bullet to match the warning callout and HISTORY wording (e.g., "default-disabled"), so it doesn't overpromise the behavior.
- Disabled Device Builder's version history feature, stopping it from committing `/config` changes to git ([device-builder#2193][device-builder-version-history-link], [device-builder#2194][device-builder-version-history-followup-link]).
Upstream will not change the default and has documented the behavior as intended, closing further issues on it. The two filed issues no longer serve as references, so point at the upstream documentation instead. Move the warning under Usage, where a reader is configuring the container and the caveat is actionable, rather than under Release Notes where it read as a changelog entry. State the consequences plainly: a fabricated commit identity the repository owner does not control, commits forced unsigned, and every commit hook bypassed - which is poor repository hygiene and breaks CI pipelines that validate commits. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
README.md:25
- The Release Notes bullet says the version history feature is "Disabled ... stopping it from committing" without the fail-open nuance that appears in the Usage warning (the entrypoint warns and continues if /config cannot be written or preferences are malformed). Reword this bullet to avoid implying the behavior is guaranteed in all cases.
- Disabled Device Builder's version history feature, stopping it from committing `/config` changes to git under a fabricated identity ([version history][device-builder-version-history-link]).
Problem
Device Builder's version history feature auto-commits every YAML change under
/configto git. It is enabled by default and exposes no environment override. Because/configis a bind mount and users commonly keep their own git repository there, the dashboard adopts that repository and starts committing to it unprompted.The commits are hostile to a normal workflow:
ESPHome Device Builder <[email protected]>identity that the repository owner does not control.commit.gpgsign=false.--no-verify.Edit <file>.yaml.That is poor repository hygiene, and it breaks CI pipelines that validate commits. On a repository with branch protection requiring signed commits the commits cannot be pushed at all, so the owner has to reset and re-commit to recover. Detection is a polling stat-based scanner rather than inotify, so it also picks up edits made on the filesystem from outside the dashboard.
Upstream documents this as intended, will not change the default, and states that further issues on the subject will be closed. So this image has to handle it locally.
Approach
The preference is
version_history_enabled, persisted at/config/.device-builder-preferences.json. Two constraints rule out the obvious fixes:/configis a bind mount and anything baked in at that path is hidden at runtime.That leaves seeding it from the entrypoint, before
exec esphome-device-builder.The preference is enforced on every start rather than seeded once. Upstream defaults it on and the failure mode is writes to somebody else's repository, so a config that drifts back on is a real risk.
ESPHOME_VERSION_HISTORY=trueis the opt-in escape hatch, mirroring the existingESPHOME_VERBOSEconvention.Seeding is fail-open: all entrypoint scripts run under
set -e, so a read-only or absent/configwarns on stderr and continues rather than aborting container startup. The temp file is created at mode0600viaos.openand atomically replaced, cleaned up if the replace fails, and a malformed existing file is left untouched rather than clobbered.Changes
Docker/entrypoint/dashboard.sh- seed the preference beforeexec.README.md- warning callout under Usage,ESPHOME_VERSION_HISTORYin theenvironmentdocumentation, 1.9 release note, reference link.HISTORY.md- 1.9 release note and reference link.cspell.json-gpgsign.Verification
The Python body was extracted from the heredoc and exercised across the fail-open matrix: fresh file writes mode
0600; an existing file keeps its other keys; opt-inTRUEflips it back on; an already-correct file is a silent no-op; malformed JSON and a JSON array are left untouched; an unwritable directory warns and exits0;os.replacepatched to fail after a successful temp write leaves no.entrypoint.tmpbehind and the original intact;os.chmodpatched to fail unconditionally still applies the setting.Exercised end to end inside the published image (
ptr727/esphome-nonroot:latest) with the real script and a bind-mounted/config:python3resolves to/opt/venv/bin/python3(3.14.6); a fresh/configseedsfalseat mode600; a restart against a realistic preferences file preservesdashboard_view,theme, andonboarding_completed_versionwhile re-enforcingfalse;ESPHOME_VERSION_HISTORY=trueopts back in; an already-correct restart is silent; no temp files remain. An unwritable/configwarns on stderr and startup still reaches the exec.Full lint gate green locally and in CI:
markdownlint-cli2,cspell,actionlint,editorconfig-checker.🤖 Generated with Claude Code