Skip to content

Add input validation limits for conversation history in /chat endpoint#97

Closed
Copilot wants to merge 4 commits intofeature/python/rag-agentfrom
copilot/sub-pr-94-another-one
Closed

Add input validation limits for conversation history in /chat endpoint#97
Copilot wants to merge 4 commits intofeature/python/rag-agentfrom
copilot/sub-pr-94-another-one

Conversation

Copy link
Copy Markdown

Copilot AI commented Nov 28, 2025

Addresses security concern where unbounded conversation history could cause memory exhaustion or excessive API costs.

Changes

  • Message count limit: Reject requests with more than MAX_MESSAGES (default: 50)
  • Content length limit: Reject requests exceeding MAX_CONTENT_LENGTH characters (default: 100,000)
  • Safe env parsing: Helper function _safe_int_env() handles invalid env values gracefully
  • Early termination: Content length validation exits loop once limit exceeded

Both limits are configurable via environment variables.

Example response on limit exceeded

{
  "error": "Too many messages. Maximum allowed is 50."
}
{
  "error": "Content too long. Maximum allowed is 100000 characters."
}

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits November 28, 2025 22:09
Co-authored-by: xujiongze <31494901+xujiongze@users.noreply.github.com>
Co-authored-by: xujiongze <31494901+xujiongze@users.noreply.github.com>
Co-authored-by: xujiongze <31494901+xujiongze@users.noreply.github.com>
Copilot AI changed the title [WIP] Update implementation based on feedback for Python rag agent Add input validation limits for conversation history in /chat endpoint Nov 28, 2025
Copilot AI requested a review from xujiongze November 28, 2025 22:14
@xujiongze xujiongze closed this Nov 29, 2025
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.

2 participants