updates: a maintenance window stored as HHMM ("1100") fails parseHM and Window.Contains then returns TRUE — the window silently becomes "any time" and an automatic patch self-applies outside it (whakatohea-demo, 19:22Z vs 11:00–13:00) #1850

Closed
opened 2026-09-24 19:29:44 +00:00 by ben · 3 comments
Owner

Symptom

whakatohea-demo, 2026-09-24 19:22Z: policy security: apply-automatically, window start "1100" / end "1300" (gateway clock UTC). The control plane polled at 19:21:58Z, found the testing cut c85d2bb3 (patch, seq 2849) and rolled it out at once — artifacts landed 19:22:03Z, self-swap 19:22:43Z — six hours outside the window. The journal has no "waiting for window" line.

Cause (read on main 41f07291)

  • internal/update/rollout.go Window.Contains → parseHM parses "%d:%d" — it accepts only HH:MM. On a parse failure Contains returns true: an unparsable window is treated as "no restriction", the same as an empty one.
  • internal/controlapi/updates.go:81 SetPolicy(…, body.Window) stores whatever the request carried — no validation, no normalisation. The demo's store holds "1100"/"1300" (HHMM, no colon), so the operator's window silently became "any time".
  • Every other consumer agrees on HH:MM (update.Window{Start: "02:00", End: "04:00"} in the seam tests, the U2 "queued for the window" copy). The value reached the store either through the U5 policy form (P4b, Edit policy → Save) or a hand edit — the fix must check what the form emits for a typed 1100 and pin it.

Why it matters

The window is the one promise the U2/U5 screens make about WHEN an unattended restart can happen (story 28, ADR 0259: "auto updates restart unattended in the window"). A malformed window turns that into "whenever the next poll runs" — including in the middle of a demo — and nothing on the surface says so.

Fix (two-way door)

  1. parseHM failure must NOT open the window: Contains on a malformed non-empty window returns false (closed until fixed), and the surface carries a standing "your maintenance window is not a valid time — updates are held" fact (ADR 0100: fail loud, never a silent all-clear).
  2. SetPolicy (API) validates both ends as HH:MM (accept and normalise HHMM / H:MM if the form can produce them) and answers 400 with a field error otherwise; the U5 form uses type="time" or validates before Save.
  3. Seam tests: "1100" → 400 on the API; a store already holding "1100" → rollout WaitingForWindow + the standing fact; "11:00" → in-window at 11:30, out at 13:30.

Related: #1811 (Update now is the sanctioned window bypass), ADR 0259, DDR 0250, internal/update/rollout.go, internal/controlapi/updates.go, P4b-U5.

## Symptom whakatohea-demo, 2026-09-24 19:22Z: policy `security: apply-automatically`, window `start "1100"` / `end "1300"` (gateway clock UTC). The control plane polled at 19:21:58Z, found the `testing` cut `c85d2bb3` (patch, seq 2849) and **rolled it out at once** — artifacts landed 19:22:03Z, self-swap 19:22:43Z — six hours outside the window. The journal has no "waiting for window" line. ## Cause (read on main `41f07291`) - `internal/update/rollout.go` `Window.Contains` → `parseHM` parses `"%d:%d"` — it accepts only `HH:MM`. On a parse failure `Contains` **returns true**: an unparsable window is treated as "no restriction", the same as an empty one. - `internal/controlapi/updates.go:81` `SetPolicy(…, body.Window)` stores whatever the request carried — no validation, no normalisation. The demo's store holds `"1100"`/`"1300"` (HHMM, no colon), so the operator's window silently became "any time". - Every other consumer agrees on `HH:MM` (`update.Window{Start: "02:00", End: "04:00"}` in the seam tests, the U2 "queued for the window" copy). The value reached the store either through the U5 policy form (P4b, `Edit policy` → Save) or a hand edit — the fix must check what the form emits for a typed `1100` and pin it. ## Why it matters The window is the one promise the U2/U5 screens make about WHEN an unattended restart can happen (story 28, ADR 0259: "auto updates restart unattended in the window"). A malformed window turns that into "whenever the next poll runs" — including in the middle of a demo — and nothing on the surface says so. ## Fix (two-way door) 1. `parseHM` failure must NOT open the window: `Contains` on a malformed non-empty window returns **false** (closed until fixed), and the surface carries a standing "your maintenance window is not a valid time — updates are held" fact (ADR 0100: fail loud, never a silent all-clear). 2. `SetPolicy` (API) validates both ends as `HH:MM` (accept and normalise `HHMM` / `H:MM` if the form can produce them) and answers 400 with a field error otherwise; the U5 form uses `type="time"` or validates before Save. 3. Seam tests: `"1100"` → 400 on the API; a store already holding `"1100"` → rollout `WaitingForWindow` + the standing fact; `"11:00"` → in-window at 11:30, out at 13:30. Related: #1811 (Update now is the sanctioned window bypass), ADR 0259, DDR 0250, `internal/update/rollout.go`, `internal/controlapi/updates.go`, P4b-U5.
Author
Owner

How "1100" got into the store — the full chain, read on main 41f07291:

  1. dashboard/src/components/provisioning/UpdatePolicyScreen.vue:85-97 — the two window inputs are plain free-text <input v-model="draft.windowStart" class="oc-input oc-input--time">, no type="time", no pattern, no validation before Save.
  2. dashboard/src/lib/localtime.ts:129 localClockToUtc(localClock) — parseHM fails on "1100" and the function returns the raw string unchanged (if (Number.isNaN(m)) return localClock;), so a typed 1100 is neither converted from the operator's zone nor rejected.
  3. internal/controlapi/updates.go:81 — SetPolicy(…, body.Window) stores it verbatim.
  4. internal/update/rollout.go:813 parseHM("%d:%d") fails → Window.Contains returns true → the window is "any time".

So an operator who types 1100 (a natural way to write 11:00) silently disables their maintenance window, and the read view then echoes 1100–1300 NZST · daily back as if it were honoured. Fix points: the form validates/normalises to HH:MM before Save (or uses type="time"), the API refuses anything else with a field error, and Contains fails CLOSED on a malformed non-empty window with a standing surface fact.

**How `"1100"` got into the store — the full chain, read on main `41f07291`:** 1. `dashboard/src/components/provisioning/UpdatePolicyScreen.vue:85-97` — the two window inputs are plain free-text `<input v-model="draft.windowStart" class="oc-input oc-input--time">`, no `type="time"`, no pattern, no validation before Save. 2. `dashboard/src/lib/localtime.ts:129` `localClockToUtc(localClock)` — `parseHM` fails on `"1100"` and the function **returns the raw string unchanged** (`if (Number.isNaN(m)) return localClock;`), so a typed `1100` is neither converted from the operator's zone nor rejected. 3. `internal/controlapi/updates.go:81` — `SetPolicy(…, body.Window)` stores it verbatim. 4. `internal/update/rollout.go:813` `parseHM("%d:%d")` fails → `Window.Contains` returns **true** → the window is "any time". So an operator who types `1100` (a natural way to write 11:00) silently disables their maintenance window, and the read view then echoes `1100–1300 NZST · daily` back as if it were honoured. Fix points: the form validates/normalises to `HH:MM` before Save (or uses `type="time"`), the API refuses anything else with a field error, and `Contains` fails CLOSED on a malformed non-empty window with a standing surface fact.

swarm-claim host=elitebook-distributed-server-03 run=32053
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=32053 (automated multi-host claim — lowest live claim id works this ticket)

close-report for #1850 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 1850,
  "status": "success",
  "commits": [
    "e868c556d57229a3a704b45f4120301ed30d763c"
  ],
  "changed_files": [
    "STATUS.md",
    "dashboard/src/components/provisioning/UpdatePolicyScreen.vue",
    "dashboard/src/lib/localtime.ts",
    "dashboard/src/lib/updatePolicy.ts",
    "dashboard/tests/unit/localtime.test.ts",
    "dashboard/tests/unit/updatePolicy.test.ts",
    "docs/GOTCHAS.md",
    "internal/controlapi/updates.go",
    "internal/controlapi/updates_integration_test.go",
    "internal/update/rollout.go",
    "internal/update/surface.go",
    "internal/update/window_test.go"
  ],
  "tests": [
    {
      "command": "nix develop .#go-ci -c go test ./internal/update/ ./internal/controlapi/",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c go vet ./internal/update/... ./internal/controlapi/... && go build ./...",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c golangci-lint run ./internal/update/... ./internal/controlapi/...",
      "exit_code": 0
    },
    {
      "command": "npx vitest run (dashboard, 153 files)",
      "exit_code": 0
    },
    {
      "command": "npx vue-tsc -p tsconfig.json --noEmit",
      "exit_code": 0
    }
  ],
  "criteria": {
    "\"1100\" -> 400 on the API": "internal/controlapi/updates.go SetPolicy handler validates both ends via update.NormalizeHM and answers 400 invalid_window; pinned by TestUpdatesHandler_SetPolicyRefusesMalformedWindow",
    "a store already holding \"1100\" -> rollout WaitingForWindow + the standing fact": "internal/update/rollout.go Window.Contains returns false on a malformed window; internal/update/surface.go sets Surface.WindowInvalid and drops Resting; pinned by TestRollout_MalformedWindow_HeldNotApplied and TestState_MalformedWindow_StandsAsFactAndNeverRests",
    "\"11:00\" -> in-window at 11:30, out at 13:30": "TestWindow_ValidHHMM_BoundedByBothEnds in internal/update/window_test.go",
    "parseHM failure must NOT open the window (fail-CLOSED + standing fact)": "Window.Contains returns false on parse failure (rollout.go:773); Window.Malformed drives Surface.WindowInvalid (surface.go); GOTCHAS #338",
    "SetPolicy (API) validates HH:MM, normalises H:MM, 400 otherwise; U5 form validates before Save": "update.NormalizeHM zero-pads H:MM; handler 400 invalid_window; UpdatePolicyScreen.vue guards Save with localtime.isLocalClock and renders WINDOW_INVALID_MESSAGE; pinned by TestUpdatesHandler_SetPolicyNormalisesValidWindow and the #1850 updatePolicy.test.ts case"
  },
  "summary": "A malformed HHMM maintenance window now fails CLOSED with a loud standing fact, the policy API rejects it with 400, and the U5 form validates before Save.",
  "blockers": []
}
**close-report** for #1850 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1850, "status": "success", "commits": [ "e868c556d57229a3a704b45f4120301ed30d763c" ], "changed_files": [ "STATUS.md", "dashboard/src/components/provisioning/UpdatePolicyScreen.vue", "dashboard/src/lib/localtime.ts", "dashboard/src/lib/updatePolicy.ts", "dashboard/tests/unit/localtime.test.ts", "dashboard/tests/unit/updatePolicy.test.ts", "docs/GOTCHAS.md", "internal/controlapi/updates.go", "internal/controlapi/updates_integration_test.go", "internal/update/rollout.go", "internal/update/surface.go", "internal/update/window_test.go" ], "tests": [ { "command": "nix develop .#go-ci -c go test ./internal/update/ ./internal/controlapi/", "exit_code": 0 }, { "command": "nix develop .#go-ci -c go vet ./internal/update/... ./internal/controlapi/... && go build ./...", "exit_code": 0 }, { "command": "nix develop .#go-ci -c golangci-lint run ./internal/update/... ./internal/controlapi/...", "exit_code": 0 }, { "command": "npx vitest run (dashboard, 153 files)", "exit_code": 0 }, { "command": "npx vue-tsc -p tsconfig.json --noEmit", "exit_code": 0 } ], "criteria": { "\"1100\" -> 400 on the API": "internal/controlapi/updates.go SetPolicy handler validates both ends via update.NormalizeHM and answers 400 invalid_window; pinned by TestUpdatesHandler_SetPolicyRefusesMalformedWindow", "a store already holding \"1100\" -> rollout WaitingForWindow + the standing fact": "internal/update/rollout.go Window.Contains returns false on a malformed window; internal/update/surface.go sets Surface.WindowInvalid and drops Resting; pinned by TestRollout_MalformedWindow_HeldNotApplied and TestState_MalformedWindow_StandsAsFactAndNeverRests", "\"11:00\" -> in-window at 11:30, out at 13:30": "TestWindow_ValidHHMM_BoundedByBothEnds in internal/update/window_test.go", "parseHM failure must NOT open the window (fail-CLOSED + standing fact)": "Window.Contains returns false on parse failure (rollout.go:773); Window.Malformed drives Surface.WindowInvalid (surface.go); GOTCHAS #338", "SetPolicy (API) validates HH:MM, normalises H:MM, 400 otherwise; U5 form validates before Save": "update.NormalizeHM zero-pads H:MM; handler 400 invalid_window; UpdatePolicyScreen.vue guards Save with localtime.isLocalClock and renders WINDOW_INVALID_MESSAGE; pinned by TestUpdatesHandler_SetPolicyNormalisesValidWindow and the #1850 updatePolicy.test.ts case" }, "summary": "A malformed HHMM maintenance window now fails CLOSED with a loud standing fact, the policy API rejects it with 400, and the U5 form validates before Save.", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#1850
No description provided.