Skip to content

fix: reject half-open delay exceeding the sliding window size#28

Merged
costela merged 1 commit into
mainfrom
fix/reject-oversize-halfopen-delay
Jun 26, 2026
Merged

fix: reject half-open delay exceeding the sliding window size#28
costela merged 1 commit into
mainfrom
fix/reject-oversize-halfopen-delay

Conversation

@costela

@costela costela commented Jun 26, 2026

Copy link
Copy Markdown
Member

What

SlidingWindowBreaker now returns an error when an explicit halfOpenDelay exceeds windowSize, instead of silently clamping it.

Why

apply clamped to windowSize whenever the delay was 0 or > windowSize. Defaulting an unset (0) value is reasonable, but silently shrinking an explicit 30s to 10s discards the caller's configuration with no signal — a least-astonishment violation. (EWMABreaker already rejects invalid half-open config loudly.)

How

  • Unset (0) still defaults to windowSize.
  • An explicit value > windowSize now errors at NewCircuit (it could never let the circuit go half-open — the window expires and closes it first).
  • WithHalfOpenDelay and NewSlidingWindowBreaker docs updated.

Notes

⚠️ Behavior change: a previously silently-clamped over-size delay now errors at construction.

🤖 Generated with Claude Code

SlidingWindowBreaker.apply silently clamped halfOpenDelay to windowSize
whenever it was 0 OR greater than windowSize. Defaulting an unset (0) value
is fine, but silently shrinking an explicit value (e.g. 30s -> 10s) discards
the caller's configuration without any signal, violating least-astonishment.

Keep defaulting the unset case, but return an error when an explicit
halfOpenDelay exceeds windowSize (such a delay could never let the circuit go
half-open, since the window expires and closes it first). This mirrors how
EWMABreaker already rejects invalid half-open configuration loudly at
construction. WithHalfOpenDelay and NewSlidingWindowBreaker docs are updated
to describe the behavior.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@marcboeker marcboeker left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@costela costela marked this pull request as ready for review June 26, 2026 19:00
@costela costela merged commit 7a76497 into main Jun 26, 2026
0 of 2 checks passed
@costela costela deleted the fix/reject-oversize-halfopen-delay branch June 26, 2026 19:01
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.

2 participants