{"record":{"id":"87f0b0976304e4b4","repo":"Tencent/WeKnora","slug":"query-is-empty","errorCode":null,"errorMessage":"query is empty","messagePattern":"query is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/infrastructure/web_search/baidu.go","lineNumber":67,"sourceCode":"\t\tapiKey:  params.APIKey,\n\t}, nil\n}\n\n// Name returns the provider name.\nfunc (p *BaiduProvider) Name() string {\n\treturn \"baidu\"\n}\n\n// Search performs a web search using Baidu AI Search API.\nfunc (p *BaiduProvider) Search(\n\tctx context.Context,\n\tquery string,\n\tmaxResults int,\n\tincludeDate bool,\n) ([]*types.WebSearchResult, error) {\n\tpreparedQuery := normalizeBaiduQuery(query)\n\tif preparedQuery == \"\" {\n\t\treturn nil, fmt.Errorf(\"query is empty\")\n\t}\n\tif preparedQuery != strings.TrimSpace(query) {\n\t\tlogger.Infof(ctx, \"[WebSearch][Baidu] normalized query to satisfy API constraints\")\n\t}\n\n\tif maxResults <= 0 {\n\t\tmaxResults = defaultBaiduResults\n\t}\n\tif maxResults > maxBaiduResults {\n\t\tmaxResults = maxBaiduResults\n\t}\n\n\tlogger.Infof(ctx, \"[WebSearch][Baidu] query=%q maxResults=%d url=%s\", preparedQuery, maxResults, p.baseURL)\n\treq, err := p.buildRequest(ctx, preparedQuery, maxResults)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresults, err := p.doSearch(ctx, req, includeDate)","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/infrastructure/web_search/baidu.go#L49-L85","documentation":"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.","triggerScenarios":"Thrown at internal/infrastructure/web_search/baidu.go:67 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure callers pass a non-empty search query","Skip the search call when the extracted query is blank"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}