Skip to content

fix: add input validation for empty chat messages#193

Open
adarshkumar23 wants to merge 1 commit intokubeflow:mainfrom
adarshkumar23:fix/add-input-validation
Open

fix: add input validation for empty chat messages#193
adarshkumar23 wants to merge 1 commit intokubeflow:mainfrom
adarshkumar23:fix/add-input-validation

Conversation

@adarshkumar23
Copy link
Copy Markdown

Summary

Add Pydantic validator to reject empty or whitespace-only messages on the /chat endpoint.

Problem

Empty or whitespace-only messages pass through to the LLM inference pipeline, wasting KServe compute resources and returning meaningless responses. No validation exists on the ChatRequest model.

Changes

  • server-https/app.py — added @validator("message") to ChatRequest that strips whitespace and rejects empty input with a 422 response

Empty or whitespace-only messages sent to /chat would be forwarded
to the LLM, wasting compute and returning meaningless responses.
Add Pydantic validator to strip whitespace and reject empty messages
with a clear 422 error before they reach the inference pipeline.

Signed-off-by: Adarsh Kumar <adarsh23072005@gmail.com>
Signed-off-by: adarshkumar23 <131923092+adarshkumar23@users.noreply.github.com>
@google-oss-prow
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign franciscojavierarceo for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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.

1 participant