Skip to content

[AI:zf-builder] refactor(server): drop vestigial error return from newRateLimitMiddleware - #174

Merged
ntsd merged 1 commit into
mainfrom
task/zf-z-b28a74de
Nov 20, 2026
Merged

ntsd merged 1 commit into
mainfrom
task/zf-z-b28a74de

Conversation

@ntsd

@ntsd ntsd commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

[AI:zf-builder] Task: zf-z-b28a74de

refactor(server): drop vestigial error return from newRateLimitMiddleware (Ponytail Rung 1)

Automated PR for task zf-z-b28a74de

Completed by: @zf-builder

…ware

Task: zf-z-b28a74de

refactor(server): drop vestigial error return from newRateLimitMiddleware (Ponytail Rung 1)
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying zerohub with  Cloudflare Pages  Cloudflare Pages

Latest commit: 06b8587
Status: ✅  Deploy successful!
Preview URL: https://80da3bda.zerohub.pages.dev
Branch Preview URL: https://task-zf-z-b28a74de.zerohub.pages.dev

View logs

@ntsd ntsd left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

[AI:zf-reviewer] [Reviewer Feedback] Round 1: Approved for human review.

Ponytail gatekeeping (7-Rung Ladder)

  • Rung 1 / 6 (YAGNI & Simplicity): This PR is itself the fix — it removes a
    provably-dead error return from newRateLimitMiddleware (the body only
    picks a key getter and returns a fresh struct; the nil error could never
    fire). Dead defensive checks at both call sites are gone. No new
    abstraction, wrapper, or premature interface introduced.
  • Rung 7 (Diff Scope & Hygiene): Tight, surgical diff — exactly the 3 files
    the task names, 4 insertions / 10 deletions. No drive-by reformatting, no
    unrelated churn, no leftover debug code. gofmt clean on all touched
    files.
  • Rungs 3 & 5 (Dependency Veto): No new packages added or removed.

Correctness verification

  • Signature is now func newRateLimitMiddleware(trustProxy bool) *rateLimitMiddleware
    (server/pkg/handler/ratelimit.go:118); doc comment describes only the
    keying semantics (no implied error path — no comment change needed).
  • Repo-wide grep confirms the only two callers (handler.go:244 in Serve,
    ratelimit_test.go:18 in startRateLimitedServer) are updated; no other
    call sites remain.
  • Behavior is byte-for-byte identical: same struct, same key-getter selection
    (remoteAddrKey vs forwardedIPKey).

Test adequacy (auto-merge strict pass)

  • cd server && go build ./... && go vet ./... — PASS.
  • go test ./pkg/handler/ -count=1 — PASS, including all 8 rate-limit tests
    that exercise newRateLimitMiddleware through startRateLimitedServer
    with both trustProxy branches
    (TestRateLimitSingleKeyPerSocket, TestRateLimitDefaultIgnoresRealIPHeader,
    TestRateLimitTrustProxyKeysByForwardedIP, plus 5 limiter unit tests).
  • Full go test ./... -count=1 server suite — PASS.
  • No new tests are required: the removed code paths were unreachable, and the
    existing suite already covers both construction branches.

Mergeability

  • mergeable: MERGEABLE, mergeStateStatus: CLEAN — no conflicts with main.

Approved.

@ntsd
ntsd merged commit 3525d70 into main Nov 20, 2026
3 checks passed
@ntsd
ntsd deleted the task/zf-z-b28a74de branch November 20, 2026 02:55
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