Repository navigation
feat(selfupdate): let operators opt out of pre-update snapshot per-update - #149
Conversation
…date Follow-up to #141. Snapshot-before-update is the right default — every operator should keep a rollback point most of the time — but there are two cases where the behaviour is friction: 1. The retained set of 5 recent snapshots already covers the operator for the kind of rollback they'd need. 2. Disk is tight (small SD card, couple hundred MB per snapshot adds up). Added a small unobtrusive checkbox under the snapshot hint: *"Skip backup for this update"*. Default unchecked (safety first). When ticked the UI sends \`{"skip_snapshot": true}\` in the POST body and the handler bypasses \`createPreUpdateSnapshot\` entirely, returning \`snapshot_skipped: true\` in the 202 response so client/log can tell the paths apart. Snapshot is still created by default for every Update click. And the deploy-time opt-out (empty SnapshotDir) keeps working exactly the same — the new body flag and the deploy flag are both honoured. Restart flow untouched (never snapshotted anyway) — no body sent there. Test: TestVersionUpdate_SkipSnapshotOptOut exercises the new path — post \`{"skip_snapshot":true}\`, verify the snapshots directory stays empty even as the handler proceeds to trigger (sidecar absence is a red herring for this assertion; we care that the snapshot step was bypassed regardless of downstream outcome). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7f657cabf7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| case "toggle-skip-snapshot": | ||
| // Don't re-render — the <input> element already reflects | ||
| // its own state and a full render would reset focus. | ||
| this._skipSnapshot = !!e.currentTarget.checked; | ||
| break; |
There was a problem hiding this comment.
Reset skip-snapshot flag after each update attempt
The checkbox handler stores skip_snapshot on component state and never clears it, so a one-time opt-out persists across later modal opens and updates. In practice, if an operator checks it once (or cancels after checking), a subsequent update can silently run without a backup even though the UI text says “for this update,” which weakens rollback safety unexpectedly.
Useful? React with 👍 / 👎.
| if r.ContentLength > 0 { | ||
| if err := readJSON(r, &body); err != nil { | ||
| writeJSON(w, 400, map[string]string{"error": "bad json: " + err.Error()}) | ||
| return | ||
| } |
There was a problem hiding this comment.
Parse JSON body even when Content-Length is unknown
Conditioning JSON decoding on r.ContentLength > 0 drops valid request bodies when the length is unknown (e.g., chunked transfer where Go exposes ContentLength == -1). In those cases {"skip_snapshot": true} is ignored and the handler takes a snapshot anyway, so behavior depends on transport/proxy details instead of request payload.
Useful? React with 👍 / 👎.
#1474 pinned d74ace6, a commit on the #149 branch. #149 has now landed on device-drivers main as 424f1e5c. Moving the pin there keeps the bundle on main and brings esphome_dsmr 1.0.7 (srcfl/device-drivers#152), the only bundled driver that differs. Signed-off-by: Fredrik Ahlgren <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Small follow-up to #141.
Summary
Why
Per-update opt-out for two real cases:
Deploy-time opt-out (empty `SnapshotDir`) continues to work exactly the same.
Test plan
🤖 Generated with Claude Code