feat: add query length validation with 20k character limit#275
feat: add query length validation with 20k character limit#275AshishKumar4 merged 1 commit intonightlyfrom
Conversation
- Add MAX_AGENT_QUERY_LENGTH constant (20,000 characters) to agent types - Validate query length in agent controller and return 413 error if exceeded - Add client-side validation in home route and chat hook with user-friendly error messages - Truncate oversized queries during state migration to prevent performance issues - Export MAX_AGENT_QUERY_LENGTH from api-types for frontend usage - Pass skipRateLimitCheck flag in createAgentSession API
b8459c3 to
715d21f
Compare
|
Claude finished @AshishKumar4's task in 2m 20s —— View job Code Quality & Security Review (Critical Path)Recommendation: APPROVE PR SummaryThis PR adds query length validation with a 20,000 character limit to prevent performance issues from extremely large prompts. It implements defense-in-depth validation on both client and server sides. PR Description
Addressed Issues
Code QualityCritical: None High: None Medium:
Low:
SecurityCritical: None High: None Medium: None Low:
Architecture Analysis
Changes Summary
Testing
Final RecommendationAPPROVE - This is a well-implemented security/performance feature that follows the project's established patterns. The defense-in-depth approach with client and server validation is the right design. The existing inline review comment about state migration truncation is valid but not blocking - it's a reasonable trade-off to prevent system degradation from legacy sessions with excessively large queries. |
Summary
Add query length validation with a 20,000 character limit to prevent performance issues from extremely large prompts. Validation is applied on both client and server sides for defense-in-depth.
Changes
MAX_AGENT_QUERY_LENGTHconstant (20,000 characters) inworker/api/controllers/agent/types.tsCodingAgentControllerreturning 413 error withSecurityErrorfor oversized queriessrc/routes/home.tsxandsrc/routes/chat/hooks/use-chat.tswith user-friendly toast messagesMAX_AGENT_QUERY_LENGTHfromsrc/api-types.tsfor frontend usagecreateAgentSessionAPI to avoid duplicate error messages (client validates first)Motivation
Large queries can cause performance degradation and excessive resource consumption during code generation. This change enforces a reasonable limit to protect the system while providing clear feedback to users.
Testing
Breaking Changes
None - this is a new validation that protects against edge cases. Existing normal usage is unaffected.