fix(ai-controller): add 2000 character max-length guard on queryBuilder prompt#274
Conversation
|
PR changed again? Review this PR in Change Stack to compare snapshots and stay oriented. Warning Review limit reached
More reviews will be available in 12 minutes and 36 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe AI query builder controller now enforces a 2000-character maximum length on the ChangesPrompt Length Constraint
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Closes #247
Problem
The
queryBuildercontroller validated thatpromptwas a non-emptystring but applied no upper-bound limit. This allowed arbitrarily large
prompts to be forwarded directly to the AI service, consuming unbounded
token quota per request.
Fix
Added a length check on
safePromptafter trimming. Prompts exceeding2000 characters are rejected with HTTP 400 before any AI service call
is made.
Changes
apps/dashboard-api/src/controllers/ai.controller.js: added max-lengthguard in
queryBuilderafter the empty-string checkSummary by CodeRabbit