fix(ingestion): validate required query field in Query handler

Empty or whitespace-only queries would silently pass through to search,
returning meaningless results. Also removed the Domain field from
queryRequest — it was accepted but silently ignored since search.Query
has no domain parameter, which would confuse callers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mathias Bergqvist
2026-04-17 20:27:02 +02:00
parent e20edd6ca9
commit d18fa0dd59
2 changed files with 18 additions and 3 deletions

View File

@@ -68,6 +68,17 @@ func TestWrite_CreatesRawFile(t *testing.T) {
assert.Contains(t, string(content), "Some content.")
}
func TestQuery_RequiresQuery(t *testing.T) {
_, h := setup(t)
body, _ := json.Marshal(map[string]any{"limit": 5})
req := httptest.NewRequest(http.MethodPost, "/query", bytes.NewReader(body))
rec := httptest.NewRecorder()
h.Query(rec, req)
assert.Equal(t, http.StatusBadRequest, rec.Code)
}
func TestWrite_GeneratesFilenameIfAbsent(t *testing.T) {
dir, h := setup(t)
body, _ := json.Marshal(map[string]any{"content": "auto name"})