fix: harden /mcp rate-limit env parsing + wire-trace-tasks portability#39
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Opened on behalf of codex's
codex/final-release-preflight-fixesbranch. Two targeted fixes plus the routine docs refresh.Real footgun fixed
The pre-existing
/mcprate-limit env parser:The
|| 60_000falls back on0/NaN, but negative numbers are truthy.MCP_HTTP_RATE_LIMIT_WINDOW_MS=-500→Number(-500) = -500→ kept verbatim → fed toexpress-rate-limit, which logs a validation error but coerces silently. Same forMCP_HTTP_RATE_LIMIT_MAX=-1. DEPLOY.md claimed "non-positive falls back" — it didn't.Plus: values above Node's
setIntervalceiling (2³¹-1 ms ≈ 24.8 days) overflow the timer in the in-memory store.Fix: extract
resolveMcpRateLimitConfig()using the existingreadPositiveInthelper + clamp atMAX_MEMORY_STORE_WINDOW_MS. Behaviour now matches the docs.Changes
src/http/app.tsresolveMcpRateLimitConfig(), used bycreateApp(). UsesreadPositiveIntfrom the shared env reader; clampswindowMsat2³¹-1.tests/http-app.test.tsDEPLOY.mdscripts/wire-trace-tasks.shCLIENT_ID/CLIENT_SECRETdirectly, orMCP_OAUTH_CLIENT_*) → Secret Manager (overridable viaCLIENT_ID_SECRET/CLIENT_SECRET_SECRET) → fallback to DEPLOY.md'scapsulemcp-client-secretname. Portable to ops contexts that don't use our specific Secret Manager naming.HOWTO.md144.74 / 171.21 KB.CHANGELOG.md[Unreleased]entry with both fixes.Test plan
npm run typecheck— cleannpm run lint— cleannpm run format:check— cleannpm run build—dist/index.js 144.74 KB,dist/http.js 171.21 KBnpm test— 463 / 463 (was 460 + 3 new env-parser tests)🤖 Generated with Claude Code