Add express-rate-limit to POST /api/generate with 5 req/min per IP to prevent AI cost runaway #170

Closed
opened 2026-04-08 23:31:16 -04:00 by pook · 5 comments
Owner

Issue #99 (rate limiting on /api/generate) exists but has no PR and the broader scope may be why. This is a minimal implementation.

Implement:

  1. Install express-rate-limit as a dependency
  2. Create src/middleware/rate-limit.ts with a limiter configured for: windowMs=60000, max=5, standardHeaders=true, legacyHeaders=false
  3. Apply ONLY to POST /api/generate route
  4. Return 429 with JSON body: {error: 'Too many requests', retryAfter: }
  5. Add integration test: send 6 rapid POST requests to /api/generate, assert first 5 return 200/401 (depending on auth), 6th returns 429

Acceptance criteria:

  • 6th request within 60s window gets 429
  • Response includes Retry-After header
  • Other routes are NOT rate-limited
  • Rate limit resets after window expires
  • Test file: tests/rate-limit.test.ts

Generated by CEO Planner (priority: 2)

Issue #99 (rate limiting on /api/generate) exists but has no PR and the broader scope may be why. This is a minimal implementation. Implement: 1. Install express-rate-limit as a dependency 2. Create src/middleware/rate-limit.ts with a limiter configured for: windowMs=60000, max=5, standardHeaders=true, legacyHeaders=false 3. Apply ONLY to POST /api/generate route 4. Return 429 with JSON body: {error: 'Too many requests', retryAfter: <seconds>} 5. Add integration test: send 6 rapid POST requests to /api/generate, assert first 5 return 200/401 (depending on auth), 6th returns 429 Acceptance criteria: - 6th request within 60s window gets 429 - Response includes Retry-After header - Other routes are NOT rate-limited - Rate limit resets after window expires - Test file: tests/rate-limit.test.ts --- *Generated by CEO Planner (priority: 2)*
Author
Owner

⚠️ Stale Task Alert — This task has been open for 6h with no associated PR.

Possible causes:

  • Worker failed to execute (check logs)
  • Claude CLI produced no changes
  • Task may be too complex for single-session execution

The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped.

— CEO Planner (automated)

⚠️ **Stale Task Alert** — This task has been open for 6h with no associated PR. Possible causes: - Worker failed to execute (check logs) - Claude CLI produced no changes - Task may be too complex for single-session execution The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped. *— CEO Planner (automated)*
Author
Owner

⚠️ Stale Task Alert — This task has been open for 6h with no associated PR.

Possible causes:

  • Worker failed to execute (check logs)
  • Claude CLI produced no changes
  • Task may be too complex for single-session execution

The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped.

— CEO Planner (automated)

⚠️ **Stale Task Alert** — This task has been open for 6h with no associated PR. Possible causes: - Worker failed to execute (check logs) - Claude CLI produced no changes - Task may be too complex for single-session execution The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped. *— CEO Planner (automated)*
Author
Owner

⚠️ Stale Task Alert — This task has been open for 6h with no associated PR.

Possible causes:

  • Worker failed to execute (check logs)
  • Claude CLI produced no changes
  • Task may be too complex for single-session execution

The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped.

— CEO Planner (automated)

⚠️ **Stale Task Alert** — This task has been open for 6h with no associated PR. Possible causes: - Worker failed to execute (check logs) - Claude CLI produced no changes - Task may be too complex for single-session execution The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped. *— CEO Planner (automated)*
Author
Owner

⚠️ Stale Task Alert — This task has been open for 7h with no associated PR.

Possible causes:

  • Worker failed to execute (check logs)
  • Claude CLI produced no changes
  • Task may be too complex for single-session execution

The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped.

— CEO Planner (automated)

⚠️ **Stale Task Alert** — This task has been open for 7h with no associated PR. Possible causes: - Worker failed to execute (check logs) - Claude CLI produced no changes - Task may be too complex for single-session execution The CEO planner will re-evaluate this task. If it remains stale for 24h+, it will be closed and re-scoped. *— CEO Planner (automated)*
Author
Owner

Closing as duplicate of #99 (rate limiting).

Closing as duplicate of #99 (rate limiting).
pook closed this issue 2026-04-09 06:12:21 -04:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot#170
No description provided.