Tencent/WeKnora · error
query is empty
Error message
query is empty
What it means
Search validates its input and rejects an empty (after TrimSpace) query string. The provider requires a non-blank query to send to the Exa API, so blank input short-circuits with this error instead of wasting an API call.
Source
Thrown at internal/infrastructure/web_search/exa.go:67
baseURL: defaultExaSearchURL,
apiKey: apiKey,
includeText: parseExaBool(params.ExtraConfig, "include_text"),
}, nil
}
// Name returns the provider type identifier.
func (p *ExaProvider) Name() string { return "exa" }
// Search performs a web search through Exa's official Search API.
func (p *ExaProvider) Search(
ctx context.Context,
query string,
maxResults int,
includeDate bool,
) ([]*types.WebSearchResult, error) {
query = strings.TrimSpace(query)
if query == "" {
return nil, fmt.Errorf("query is empty")
}
if maxResults <= 0 {
maxResults = defaultExaResults
}
if maxResults > maxExaResults {
maxResults = maxExaResults
}
bodyBytes, err := json.Marshal(exaSearchRequest{
Query: query,
NumResults: maxResults,
Contents: exaContents{
Highlights: true,
Text: p.includeText,
},
})
if err != nil {
return nil, fmt.Errorf("failed to marshal Exa request: %w", err)View on GitHub (pinned to 988cbb0330)
Solutions
- Validate/trim the query in the caller before invoking Search and skip the call if empty
- Return a user-facing 'please enter a search term' message for blank input
- Check upstream string extraction for bugs that strip content
- Guard pipeline steps so unset variables do not flow into Search
Example fix
// before
results, err := provider.Search(ctx, userQuery, 10, false)
// after
userQuery = strings.TrimSpace(userQuery)
if userQuery == "" {
return nil, ErrEmptyQuery
}
results, err := provider.Search(ctx, userQuery, 10, false) Defensive patterns
Strategy: validation
Validate before calling
q := strings.TrimSpace(userQuery)
if q == "" {
return nil, errors.New("search query must not be empty")
} Try / catch
results, err := provider.Search(ctx, userQuery, 10, false)
if err != nil && strings.Contains(err.Error(), "query is empty") {
return nil, userFacingError("Please enter a search term.")
} Prevention
- Trim and validate user input at the API boundary before calling providers
- Disable/validate empty search submissions in the frontend
- Check text-extraction pipelines for whitespace-only outputs
- Centralize query sanitization in one shared helper
When it happens
Trigger: Calling Search with query "" or a whitespace-only string — e.g. user submitted an empty search box, upstream trimmed/parsed the query away, or a pipeline passed an unset variable.
Common situations: Frontend allowing empty search submissions, string extraction from documents yielding only whitespace, locale/encoding bugs stripping the query, passing an unbound variable from a template.
Related errors
- query is empty
- model ID cannot be empty
- unknown credential field:
- member_limit must be >= 0
- cannot request upgrade to same or lower role
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/4ef8779ac4eb149f.
Report an issue: GitHub.