Skip to content

fix: reject empty queries in search and embed endpoints#23

Open
echobt wants to merge 1 commit intomainfrom
fix/issue-101
Open

fix: reject empty queries in search and embed endpoints#23
echobt wants to merge 1 commit intomainfrom
fix/issue-101

Conversation

@echobt
Copy link
Copy Markdown
Contributor

@echobt echobt commented Jan 20, 2026

This PR adds validation to the /search, /embed, and /embed_batch endpoints to reject empty or whitespace-only inputs.

Changes

  • Modified search handler to return 400 Bad Request if query is empty or whitespace.
  • Modified embed handler to return 400 Bad Request if text is empty or whitespace.
  • Modified embed_batch handler to return 400 Bad Request if the list is empty or contains only empty strings.
  • Added logic verification tests in src/server/api_tests.rs.

Reason

Empty queries waste resources by generating embeddings and searching the database for meaningless input. This validation prevents unnecessary computation and returns a clear error to the client.

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.

1 participant