Skip to content

fix(core): fail closed when Gemini RPD counter is unavailable (#72)#77

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-inspection-4f45
Draft

fix(core): fail closed when Gemini RPD counter is unavailable (#72)#77
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-inspection-4f45

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented May 3, 2026

What

  • Make bot and quiz Gemini RPD counter increments fail closed when DynamoDB cannot update the counter.
  • Map counter-unavailable failures to existing provider-unavailable errors so callers use the established fallback/error paths instead of calling Gemini unmetered.
  • Add regression tests proving DynamoDB update failures do not proceed to Gemini API calls.

Why

  • A DynamoDB UpdateItem failure previously returned (0, True), bypassing the daily Gemini RPD guard.
  • Concrete impact: table outage, IAM misconfiguration, throttling, or region/account mismatch allowed unbounded Gemini requests with no counter movement, defeating quota controls and fallback policy.

Verification

  • python3 -m pytest tests/test_rate_limit_fail_closed.py tests/test_explain_multimodal.py tests/test_quiz_generator.py
  • python3 -m pytest

πŸ“ Description

Fail closed when Gemini RPD counters cannot be incremented safely.

πŸš€ Type of Change

  • πŸ› Bug Fix (Fix an issue)
  • ✨ New Feature (Add a new feature)
  • πŸ—οΈ Infrastructure (CDK/AWS resource changes)
  • ♻️ Refactoring (Code refactoring, no logic changes)
  • πŸ“š Documentation (Documentation update)

πŸ—οΈ Infrastructure Changes (Crucial)

  • Resources Created: None
  • Resources Modified: None
  • Resources Deleted: None
  • Cost Impact: Prevents unexpected Gemini usage when DynamoDB quota accounting is unavailable.

βœ… Checklist

  • I have performed a self-review of my code.
  • I have run pre-commit run --all-files locally and fixed all issues.
  • I have added/updated Unit Tests (pytest).
  • My changes do not generate new warnings.
  • (If Infra change) I have run cdk diff locally to verify changes.

πŸ”— Related Issues

Open in WebΒ View AutomationΒ 

Co-authored-by: Bayashat <baiashat2002@gmail.com>
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