Skip to content

Add MAX_QUERY_LENGTH guard in handle_chat to prevent overly long queries (#83)#90

Open
tisha-varma wants to merge 1 commit intoINCF:mainfrom
tisha-varma:fix/query-length-guard
Open

Add MAX_QUERY_LENGTH guard in handle_chat to prevent overly long queries (#83)#90
tisha-varma wants to merge 1 commit intoINCF:mainfrom
tisha-varma:fix/query-length-guard

Conversation

@tisha-varma
Copy link
Contributor

This PR adds a configurable query length guard in handle_chat to prevent excessively long inputs from reaching the Gemini API.

Changes:

  • Introduced MAX_QUERY_LENGTH environment variable (default: 2000 chars)
  • Added early validation in handle_chat
  • Trimmed whitespace before validation
  • Added tests to verify guard behavior
  • Documented MAX_QUERY_LENGTH in .env.template

This prevents token limit errors from large inputs and provides users with a clear, friendly message.

Fixes #83

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.

enhancement: Add query length guard in handle_chat

1 participant