Tencent/WeKnora · error

query is empty

Error message

query is empty

What it means

Input validation at the top of BaiduProvider.Search: normalizeBaiduQuery (which enforces the Baidu AI Search API's query constraints) reduced the input to an empty string — the raw query was empty or contained only characters the API forbids. The search is aborted before any request is built.

Source

Thrown at internal/infrastructure/web_search/baidu.go:67

		apiKey:  params.APIKey,
	}, nil
}

// Name returns the provider name.
func (p *BaiduProvider) Name() string {
	return "baidu"
}

// Search performs a web search using Baidu AI Search API.
func (p *BaiduProvider) Search(
	ctx context.Context,
	query string,
	maxResults int,
	includeDate bool,
) ([]*types.WebSearchResult, error) {
	preparedQuery := normalizeBaiduQuery(query)
	if preparedQuery == "" {
		return nil, fmt.Errorf("query is empty")
	}
	if preparedQuery != strings.TrimSpace(query) {
		logger.Infof(ctx, "[WebSearch][Baidu] normalized query to satisfy API constraints")
	}

	if maxResults <= 0 {
		maxResults = defaultBaiduResults
	}
	if maxResults > maxBaiduResults {
		maxResults = maxBaiduResults
	}

	logger.Infof(ctx, "[WebSearch][Baidu] query=%q maxResults=%d url=%s", preparedQuery, maxResults, p.baseURL)
	req, err := p.buildRequest(ctx, preparedQuery, maxResults)
	if err != nil {
		return nil, err
	}
	results, err := p.doSearch(ctx, req, includeDate)

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Ensure callers pass a non-empty search query
  2. Skip the search call when the extracted query is blank
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/infrastructure/web_search/baidu.go:67 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/87f0b0976304e4b4. Report an issue: GitHub.