Tencent/WeKnora · warning
query is empty
Error message
query is empty
What it means
KeenableProvider.Search guards against an empty query string and returns this error before issuing the HTTP POST. It mirrors the same guard as the Google provider so callers get a consistent, immediate failure instead of a meaningless remote search.
Source
Thrown at internal/infrastructure/web_search/keenable.go:68
baseURL: defaultKeenableBaseURL,
apiKey: params.APIKey,
}, nil
}
// Name returns the provider name
func (p *KeenableProvider) Name() string {
return "keenable"
}
// Search performs a web search using the Keenable Search API.
func (p *KeenableProvider) Search(
ctx context.Context,
query string,
maxResults int,
includeDate bool,
) ([]*types.WebSearchResult, error) {
if len(query) == 0 {
return nil, fmt.Errorf("query is empty")
}
if maxResults <= 0 {
maxResults = defaultKeenableResults
}
// Keyless by default; a configured key switches to the authenticated path.
path := "/v1/search/public"
if p.apiKey != "" {
path = "/v1/search"
}
endpoint := p.baseURL + path
logger.Infof(ctx, "[WebSearch][Keenable] query=%q maxResults=%d url=%s", query, maxResults, endpoint)
bodyBytes, err := json.Marshal(keenableSearchRequest{Query: query, Mode: "pro"})
if err != nil {
return nil, fmt.Errorf("failed to marshal request: %w", err)
}
View on GitHub (pinned to 988cbb0330)
Solutions
- Trim and validate the query in the calling code before calling Search.
- Skip search flow entirely for empty queries and respond with a prompt for more input.
- Add a unit test covering the empty-query path of your integration layer.
Example fix
// before
results, err := keenable.Search(ctx, query, 10, false)
// after
query = strings.TrimSpace(query)
if query == "" {
return nil, errors.New("cannot search: query is empty")
}
results, err := keenable.Search(ctx, query, 10, false) Defensive patterns
Strategy: validation
Validate before calling
q := strings.TrimSpace(userQuery)
if q == "" {
return nil, errors.New("cannot perform keenable search: empty query")
}
return keenable.Search(ctx, q, maxResults, false) Try / catch
results, err := keenable.Search(ctx, q, n, false)
if err != nil && err.Error() == "query is empty" {
return nil, errors.New("please provide search terms")
} Prevention
- Validate query non-empty (and trimmed) before any provider call
- Handle empty upstream NLU output before it reaches the search layer
- Cover empty-query branches in unit tests
- Share one query-normalization helper across all search providers
When it happens
Trigger: Calling keenable.Search(ctx, "", maxResults, includeDate) — empty or never-populated query (tests TestKeenableProvider_Search_* exercise this path).
Common situations: Caller passes untrimmed user input that is empty; upstream NLU produced no terms; a variable defaulting to "" was forwarded directly.
Related errors
- query is empty
- member_limit must be >= 0
- API key is required for Ollama provider
- API key is required for Baidu provider
- API key is required for Exa provider
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/17b5d83b19bd913d.
Report an issue: GitHub.