{"record":{"id":"591968c079e74874","repo":"Tencent/WeKnora","slug":"create-baidu-http-client-w","errorCode":null,"errorMessage":"create Baidu HTTP client: %w","messagePattern":"create Baidu HTTP client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/infrastructure/web_search/baidu.go","lineNumber":44,"sourceCode":"\tmaxBaiduResults          = 50\n\tmaxBaiduQueryUnits       = 72\n)\n\n// BaiduProvider implements web search using Baidu AI Search API.\ntype BaiduProvider struct {\n\tclient  *http.Client\n\tbaseURL string\n\tapiKey  string\n}\n\n// NewBaiduProvider creates a new Baidu web search provider from parameters.\nfunc NewBaiduProvider(params types.WebSearchProviderParameters) (interfaces.WebSearchProvider, error) {\n\tif params.APIKey == \"\" {\n\t\treturn nil, fmt.Errorf(\"API key is required for Baidu provider\")\n\t}\n\tclient, err := NewSearchHTTPClient(defaultBaiduTimeout, params.ProxyURL)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"create Baidu HTTP client: %w\", err)\n\t}\n\treturn &BaiduProvider{\n\t\tclient:  client,\n\t\tbaseURL: defaultBaiduWebSearchURL, // Hardcoded — not tenant-configurable\n\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,","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/infrastructure/web_search/baidu.go#L26-L62","documentation":"Returned by NewBaiduProvider when NewSearchHTTPClient fails to build the outbound HTTP client — typically an invalid proxy_url that failed validation, or the default transport not being *http.Transport.","triggerScenarios":"Thrown at internal/infrastructure/web_search/baidu.go:44 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the proxy_url parameter for correct format (scheme://host:port)","Remove the proxy setting if none is required","Verify the environment's default transport is unmodified"],"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"}