Skip to content

Refuse a timer-backed timing longer than about 49.7 days [patch] - #122

Open
matt-edmondson wants to merge 1 commit into
mainfrom
fix/121-cap-timer-timings
Open

matt-edmondson wants to merge 1 commit into
mainfrom
fix/121-cap-timer-timings

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #121

What changed

FetchTimeout, DiffTimeout, ProbeTimeout and MaintenanceInterval were only checked to be positive. They are passed to CancellationTokenSource, Task.WaitAsync and PeriodicTimer, and all three throw ArgumentOutOfRangeException past uint.MaxValue - 1 ms (about 49.7 days).

The validator now refuses those four settings above MaxTimerDuration (TimeSpan.FromMilliseconds(uint.MaxValue - 1)). The failure message names the setting, the value and the limit, the same way a non-positive value or a relative MirrorRoot is already refused. The check sits next to RequirePositive, in a new RequirePositiveTimerDuration. RefsTtl and AdmissionTtl never reach a timer, so they are unchanged.

Tests

  • Validate_TimerSettingOf49Days_Succeeds checks that each of the four settings accepts 49 days.
  • Validate_TimerSettingOf50Days_Fails checks that each of the four refuses 50 days, with the setting name and the limit in the message. These four cases fail when the bound is neutralised.
  • MaxTimerDuration_IsTheLongestDurationTheTimersAccept pins the constant against the real APIs: the maximum is accepted, and 1 ms more throws for both CancellationTokenSource and PeriodicTimer.

The full suite passes (317 tests).


Generated by Claude Code

FetchTimeout, DiffTimeout, ProbeTimeout and MaintenanceInterval were only
checked to be positive, but they are handed to CancellationTokenSource,
Task.WaitAsync and PeriodicTimer, which throw ArgumentOutOfRangeException
past uint.MaxValue - 1 milliseconds. A value such as 365.00:00:00 meant as
"effectively no timeout" passed validation and then stopped startup with a
raw exception, or made every request needing a fetch or diff fail with a
500. The validator now refuses it with a message naming the setting, the
value and the limit.

Fixes #121

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW5wqHMdBMn6Wino1eH
@sonarqubecloud

sonarqubecloud Bot commented Nov 5, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants