Repository navigation
Description
mcpx(settings): non-positive durations pass validation, then panic the daemon at time.NewTicker — reapInterval/saveInterval/ssePing accept -5s and 0s
Summary
KindDuration settings are validated only for parseability, never for sign. Interval settings that are spent directly as time.NewTicker periods therefore accept -5s and 0s at every layer (file / env / flag / preset / runtime override), and the daemon later panics with non-positive interval for NewTicker — at startup for the reap/save tickers, and on the first SSE events request for the ping ticker. This is the duration sibling of #1697 (byte sizes accept negatives/overflow and panic a make cap); that issue's fix does not reach this one, because the values here parse cleanly and overflow nothing.
Evidence (verified this run, main fbedd80)
Line trace, pkgs/mcpx:
internal/settings/value.go:499-502—Validate'sKindDurationcase only checkstime.ParseDuration(raw)succeeds.-5sand0sboth parse, so both are valid settings.SetRuntime/Applygate onNormalize→Validate, so the bad value is admitted at every layer.internal/settings/value.go:317-320—Set.Duration()re-parses with the error discarded and returns the value verbatim.- Declarations with no floor/positivity constraint:
daemon.reapInterval(internal/settings/registry.go:474, default30s),daemon.saveInterval(registry.go:480, default5m),http.ssePing(internal/settings/wire.go:61). - Unguarded consumers:
internal/daemon/server.go:539-542—Serve()doestime.NewTicker(s.set.Duration("daemon.reapInterval"))and the same forsaveInterval, unconditionally, before the serve loop;internal/daemon/server.go:1447— the SSE handler doestime.NewTicker(s.set.Duration("http.ssePing")). - The guarded contrast exists in the same package:
internal/daemon/routes_exec.go:110-114—collectArtifactssubstitutes the default whenevery <= 0before callingNewTicker. The reap/save/ping sites have no equivalent guard, which is why this stayed hidden.
Laptop probe (real internal/settings package; worktree ~/git/fleet/probe-2026-10-30-laneA-durticker on the laptop at 541578a — internal/settings/value.go sha256 c669f256… and internal/daemon/server.go sha256 a5efbdc6… are byte-identical to sandbox main fbedd80):
SetRuntime(daemon.reapInterval, "-5s") ACCEPTED; Duration()=-5s
time.NewTicker(-5s) PANICS: non-positive interval for NewTicker
SetRuntime(daemon.reapInterval, "0s") ACCEPTED; Duration()=0s
time.NewTicker(0s) PANICS: non-positive interval for NewTicker
SetRuntime(daemon.saveInterval, "-1s") ACCEPTED; Duration()=-1s -> NewTicker PANICS
SetRuntime(http.ssePing, "-1s") ACCEPTED; Duration()=-1s -> NewTicker PANICS
SetRuntime(http.ssePing, "0s") ACCEPTED; Duration()=0s -> NewTicker PANICS
Validate(<real registry decl>, "-5s") err=<nil>; Validate(..., "0s") err=<nil> (all three decls)
Why it matters
The settings system is the one choke point whose job is keeping an invalid value out of a running process (the #1697 reasoning). An interval of -1s/0s is an easy typo or generated-config artefact, and here it does not degrade anything — it crashes the daemon outright at startup (reap/save) or takes down an SSE request handler goroutine (ping). Other duration settings may legitimately mean something at zero (e.g. daemon.idleExit defaults to 0s = disabled), so this cannot be fixed by a blanket "all durations must be > 0" rule; the interval/poll class needs its own pin.
Acceptance criteria
- Interval-class duration settings — at minimum
daemon.reapInterval,daemon.saveInterval,http.ssePing, and any other setting a consumer spends as aNewTicker/Tickperiod (triage to enumerate: e.g.proto.askPoll,protoTasks.pollInterval,transport.sseKeepAlive,autostart.pollInterval) — refuse zero and negative values atValidate/Normalizetime, with an error naming the value, at every layer (file/env/flag/preset/runtime). - Duration settings where zero is a documented "disabled/never" meaning (e.g.
daemon.idleExit) keep accepting0s; triage pins which class each duration setting belongs to rather than applying one global rule. - No
NewTickercall site reachable from a settings duration can panic on a validated value (either validation refuses it, or the site guards likecollectArtifactsdoes). - Regression tests cover
-5sand0sfor at least the three named settings plus one legitimate-zero setting staying accepted; existinginternal/settingsandinternal/daemontests keep passing.
Notes for triage
- Where the positivity pin lives (a per-setting floor/class on the declaration vs a consumer-side guard) is the decision this filing leaves to triage — hence
task/triage, not a self-solve. - Distinct from: mcpx(settings): byte sizes accept negatives and int64 overflow — http.streamBufferInit=-1 passes validation, then panics the CLI with 'makeslice: cap out of range' at the first streaming read #1697 (KindBytes negatives/overflow,
makecap panic — different kind, different consumer); mcpx(adapter): a negative timeout passes Validate and makes every tool call fail instantly — parseDuration accepts -5s, Run's WithTimeout is born expired and reports 'did not finish within -5s' #1758 (closed; adapter's ownparseDuration, not the settings system); mcpx(plugin): goDurationMs returns Infinity for overflow durations Go rejects — one typo'd MCPX_PLUGIN_DISCOVERY_RETRY disables daemon rediscovery for the whole session #2309 (plugingoDurationMsoverflow → Infinity, a JS-side conversion). - Found by new-issue-creator lane A, 2026-10-30.
Activity
dezren39 commentedon Oct 30, 2026
agent: new-issue-creator-code-a
state: filed
found_via: filed this run
issue: 2613
Filed this run after verification with the real
internal/settingspackage on the laptop (probe~/git/fleet/probe-2026-10-30-laneA-durticker/; key files byte-identical to main fbedd80):SetRuntimeaccepts-5s/0sfordaemon.reapInterval,daemon.saveIntervalandhttp.ssePing, andtime.NewTickerpanics on each resulting value. The unguarded consumers areinternal/daemon/server.go:539-542(daemon startup) and:1447(SSE handler);collectArtifacts(routes_exec.go:110-114) shows the guarded pattern. NOT self-solved: which duration settings are interval-class (must be >0) vs legitimate-zero (e.g.daemon.idleExit) is triage's pin. Dedup: #1697 is KindBytes, #1758 (closed) is the adapter's own parser, #2309 is the plugin JS conversion.dezren39 commentedon Nov 1, 2026
🤖 Agent note · state: claimed
dezren39 commentedon Nov 1, 2026
🤖 Agent note · state: done