Skip to content

fix(config): a zero control interval or watchdog means unset - #1903

Merged
frahlg merged 1 commit into
masterfrom
f5-zero-site-setting-means-unset
Oct 27, 2026
Merged

frahlg merged 1 commit into
masterfrom
f5-zero-site-setting-means-unset

Conversation

@frahlg

@frahlg frahlg commented Oct 27, 2026

Copy link
Copy Markdown
Member

Item F5 of the stable plan.

Problem

POST /api/config never fills defaults, Validate accepts 0 for site.control_interval_s, and a stored-settings load fills no defaults either. A save that leaves out the control interval, or sends 0, returns 200 and stores 0. The running loop goes on at 2 s, so nobody notices. On the next restart or self-update, time.NewTicker(0) panics at main.go:2854 and Core restarts in a loop.

The on-box UI can do this with no script: emptying the "Control interval (s)" field sends parseFloat(""), which becomes 0.

A stored watchdog_timeout_s: 0 is broken the same way: several watchdog paths (main.go:2964 and others) would treat every driver as stale.

Repro on master: a POST with only site.name and site.smoothing_alpha (plus fuse, api and drivers) returns 200. The reload then reads interval=0 watchdog=0, and the boot ticker panics with "non-positive interval for NewTicker".

Change

  • config.Site.FillUnsetTimings() treats 0 as unset for control_interval_s (2 s) and watchdog_timeout_s (60 s). applyDefaults now calls it, so the YAML path keeps the same defaults from one place.
  • decodeStored calls it, so a box that already stored a 0 starts again.
  • The plain settings POST calls it. The reviewed setup path does not, because a reviewed draft must save exactly as reviewed; the next load fills it.
  • Boot uses the tick's <=0 -> 2 s guard, and dtS comes from the guarded interval.

Other site fields keep their stored zeros on purpose. Zero slew means "no limit" (dispatch.go:2186-2193), zero tolerance means no dead band, zero holdoff means no holdoff, and the runtime already ignores zero gain.

Tests

  • TestPartialConfigPostSurvivesRestart (go/cmd/ftw, from audit worktree caa-109): fails on master with the NewTicker panic, passes here. It now also asserts the reloaded interval is 2 and the watchdog 60.
  • TestStoredZeroTimingsLoadAsDefaults (go/internal/config): a stored 0 loads as 2 s and 60 s, and a stored zero slew stays 0.
  • go test -race -count=1 ./cmd/ftw/... ./internal/api/... ./internal/config/...: ok.
  • go vet ./... and go build ./...: ok.

Risk

Low. A box that stored 0 for either field now runs with the default instead of crashing, or instead of treating every driver as stale. No other stored value changes.

🤖 Generated with Claude Code

A settings POST that omits control_interval_s stored 0, and the next
boot panicked in time.NewTicker. Fill the two site timings that have no
meaning at zero on every decoded document (YAML, stored settings and a
plain settings POST), and give boot the tick's <=0 -> 2 s guard.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T13:45:23.546209Z 2ca90a5 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@frahlg
frahlg merged commit 8c66c4a into master Oct 27, 2026
23 checks passed
@frahlg
frahlg deleted the f5-zero-site-setting-means-unset branch November 11, 2026 09:16
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.

1 participant