Skip to content

fix: Reject empty search queries with validation (Issue #175)#179

Merged
rdmueller merged 1 commit intodocToolchain:mainfrom
raifdmueller:fix/empty-search-query-175
Jan 26, 2026
Merged

fix: Reject empty search queries with validation (Issue #175)#179
rdmueller merged 1 commit intodocToolchain:mainfrom
raifdmueller:fix/empty-search-query-175

Conversation

@raifdmueller
Copy link
Collaborator

Summary

Implements validation for empty search queries in both CLI and MCP interfaces.

Changes

  • CLI (src/dacli/cli.py): Validate query before search, exit with EXIT_INVALID_ARGS (code 2)
  • MCP (src/dacli/mcp_app.py): Raise ValueError for empty queries (wrapped in ToolError by FastMCP)
  • Tests: Added comprehensive tests for both CLI and MCP

Behavior

Empty string:

$ dacli search ""
Error: Search query cannot be empty
$ echo $?
2

Whitespace only:

$ dacli search "   "
Error: Search query cannot be empty
$ echo $?
2

Test Results

tests/test_cli.py::test_search_empty_query_returns_error PASSED
tests/test_cli.py::test_search_whitespace_only_query_returns_error PASSED
tests/test_mcp_tools.py::test_search_empty_query_raises_error PASSED
tests/test_mcp_tools.py::test_search_whitespace_query_raises_error PASSED

All 105 tests passing.

Fixes #175


🤖 Generated with Claude Code

@raifdmueller raifdmueller force-pushed the fix/empty-search-query-175 branch from e6133c1 to ea77bf9 Compare January 26, 2026 12:20
)

- Add validation for empty/whitespace-only queries in CLI and MCP
- CLI exits with EXIT_INVALID_ARGS (exit code 2)
- MCP raises ValueError wrapped in ToolError
- Add comprehensive tests for both interfaces
- Error message: 'Search query cannot be empty'

Fixes docToolchain#175
@raifdmueller raifdmueller force-pushed the fix/empty-search-query-175 branch from ea77bf9 to c504066 Compare January 26, 2026 13:52
@rdmueller rdmueller merged commit 7df79c0 into docToolchain:main Jan 26, 2026
4 checks passed
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.

Empty search query should show warning or error

2 participants