Skip to content

Disable Device Builder version history auto-commit by default - #169

Merged
ptr727 merged 6 commits into
developfrom
fix/disable-version-history-auto-commit
Jul 19, 2026
Merged

ptr727 merged 6 commits into
developfrom
fix/disable-version-history-auto-commit

Conversation

@ptr727

@ptr727 ptr727 commented Jul 19, 2026 •

Copy link
Copy Markdown
Owner

Problem

Device Builder's version history feature auto-commits every YAML change under /config to git. It is enabled by default and exposes no environment override. Because /config is 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:

  • Attributed to a fabricated ESPHome Device Builder <[email protected]> identity that the repository owner does not control.
  • Forced unsigned, via commit.gpgsign=false.
  • Every commit hook bypassed, via --no-verify.
  • One commit per file, message 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:

  • The image cannot ship the file, because /config is a bind mount and anything baked in at that path is hidden at runtime.
  • The store is RAM-canonical with a debounced write plus a shutdown flush, so patching the file while the dashboard runs is overwritten.

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=true is the opt-in escape hatch, mirroring the existing ESPHOME_VERBOSE convention.

Seeding is fail-open: all entrypoint scripts run under set -e, so a read-only or absent /config warns on stderr and continues rather than aborting container startup. The temp file is created at mode 0600 via os.open and 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 before exec.
  • README.md - warning callout under Usage, ESPHOME_VERSION_HISTORY in the environment documentation, 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-in TRUE flips 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 exits 0; os.replace patched to fail after a successful temp write leaves no .entrypoint.tmp behind and the original intact; os.chmod patched 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: python3 resolves to /opt/venv/bin/python3 (3.14.6); a fresh /config seeds false at mode 600; a restart against a realistic preferences file preserves dashboard_view, theme, and onboarding_completed_version while re-enforcing false; ESPHOME_VERSION_HISTORY=true opts back in; an already-correct restart is silent; no temp files remain. An unwritable /config warns 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

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]>
Copilot AI review requested due to automatic review settings July 19, 2026 01:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.json from Docker/entrypoint/dashboard.sh before starting esphome-device-builder, defaulting version history off unless explicitly enabled via ESPHOME_VERSION_HISTORY.
  • Add documentation/release-note callouts in README.md and HISTORY.md describing 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.

Comment thread README.md Resolved
Comment thread HISTORY.md Resolved
Comment thread Docker/entrypoint/dashboard.sh Resolved
Comment thread Docker/entrypoint/dashboard.sh Resolved
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]>
Copilot AI review requested due to automatic review settings July 19, 2026 01:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 /config is 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]).

Comment thread Docker/entrypoint/dashboard.sh Resolved
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]>
Copilot AI review requested due to automatic review settings July 19, 2026 01:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`.

Comment thread Docker/entrypoint/dashboard.sh Resolved
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]>
Copilot AI review requested due to automatic review settings July 19, 2026 01:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]).

Comment thread README.md Resolved
Comment thread README.md Resolved
Comment thread HISTORY.md Resolved
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]>
Copilot AI review requested due to automatic review settings July 19, 2026 01:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 /config is 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]>
Copilot AI review requested due to automatic review settings July 19, 2026 02:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]).

@ptr727
ptr727 merged commit 4f494d5 into develop Jul 19, 2026
12 checks passed
@ptr727
ptr727 deleted the fix/disable-version-history-auto-commit branch July 19, 2026 02:56
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.

2 participants