Skip to content

chore: dev to main merge#848

Open
Ragini-Microsoft wants to merge 6 commits into
mainfrom
dev
Open

chore: dev to main merge#848
Ragini-Microsoft wants to merge 6 commits into
mainfrom
dev

Conversation

@Ragini-Microsoft
Copy link
Copy Markdown
Collaborator

Purpose

This pull request improves input validation for the /api/chat endpoint, ensuring that requests with missing or empty message content are properly rejected with a 400 error unless an action is specified. It also updates and expands the test suite to verify these new validation rules.

API validation improvements:

  • Added checks in handle_chat (in app.py) to return a 400 error if the request body is empty or if the message field is missing or contains only whitespace (unless an action is specified).

Testing updates:

  • Updated and added tests in test_app.py to assert that the chat endpoint rejects empty or whitespace-only messages, as well as empty request bodies, with the appropriate 400 error response.
  • Modified existing tests to expect 400 errors for missing message scenarios, and clarified that action-based requests can still have empty messages. [1] [2] [3]

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
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 /api/chat request validation so empty request bodies and missing/blank messages are rejected unless an explicit action is provided, and updates backend tests to reflect the new validation behavior.

Changes:

  • Added early 400 responses in handle_chat for empty request data and blank message content.
  • Updated chat endpoint tests to expect validation failures for missing/empty messages.
  • Added coverage for whitespace-only messages and action-based empty-message requests.

Reviewed changes

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

File Description
src/backend/app.py Adds request-body and message-content validation to /api/chat.
src/tests/test_app.py Updates and adds tests for the new chat validation behavior.

💡 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
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.

4 participants