Skip to content

fix: Add validation for empty request body and message content in chat handler#846

Merged
Avijit-Microsoft merged 4 commits into
devfrom
rc-bug1205
May 12, 2026
Merged

fix: Add validation for empty request body and message content in chat handler#846
Avijit-Microsoft merged 4 commits into
devfrom
rc-bug1205

Conversation

@Ragini-Microsoft

Copy link
Copy Markdown
Collaborator

Purpose

This pull request adds improved input validation to the unified chat endpoint in app.py. The main changes ensure that the endpoint returns clear error messages for missing or empty request data, which helps prevent processing invalid requests and improves the API's robustness.

Input validation improvements:

  • Added a check to return a 400 error if the request body is missing, with a descriptive error message in the response.
  • Added a check to return a 400 error if both the action and message fields are empty or missing, ensuring that chat requests include meaningful content.

Does this introduce a breaking change?

  • Yes
  • No

Golden Path Validation

  • I have tested the primary workflows (the "golden path") to ensure they function correctly without errors.

Deployment Validation

  • I have validated the deployment process successfully and all services are running as expected with this change.

@github-actions

github-actions Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens input validation for the Quart unified chat endpoint (/api/chat) to reject missing/empty request bodies and empty message content when no action is provided, improving API robustness and error clarity.

Changes:

  • Added an early 400 response when the request JSON body is missing/empty.
  • Added a 400 response when both action is absent and message is empty/whitespace.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/backend/app.py
Comment thread src/backend/app.py
Comment thread src/backend/app.py
Copilot AI review requested due to automatic review settings May 12, 2026 07:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread src/backend/app.py
Comment thread src/backend/app.py
@Avijit-Microsoft
Avijit-Microsoft merged commit 0d06ce5 into dev May 12, 2026
5 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 2.5.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@Ragini-Microsoft
Ragini-Microsoft deleted the rc-bug1205 branch May 25, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants