{"record":{"id":"a1516af895df8979","repo":"Tencent/WeKnora","slug":"failed-to-unmarshal-response-w","errorCode":null,"errorMessage":"failed to unmarshal response: %w","messagePattern":"failed to unmarshal response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/infrastructure/web_search/baidu.go","lineNumber":140,"sourceCode":"\tresp, err := p.client.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\n\tbody, err := io.ReadAll(io.LimitReader(resp.Body, 2<<20)) // 2MB limit\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif resp.StatusCode != http.StatusOK {\n\t\tlogger.Warnf(ctx, \"[WebSearch][Baidu] API returned status %d: %s\", resp.StatusCode, string(body))\n\t\treturn nil, fmt.Errorf(\"baidu API returned status %d: %s\", resp.StatusCode, string(body))\n\t}\n\n\tvar respData baiduSearchResponse\n\tif err := json.Unmarshal(body, &respData); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to unmarshal response: %w\", err)\n\t}\n\n\t// Check for API-level error (returned with 200 status)\n\tif respData.Code != 0 {\n\t\treturn nil, fmt.Errorf(\"baidu API error (code %d): %s\", respData.Code, respData.Message)\n\t}\n\n\tresults := make([]*types.WebSearchResult, 0, len(respData.References))\n\tfor _, ref := range respData.References {\n\t\tresult := &types.WebSearchResult{\n\t\t\tTitle:   ref.Title,\n\t\t\tURL:     ref.URL,\n\t\t\tContent: ref.Content,\n\t\t\tSource:  \"baidu\",\n\t\t}\n\n\t\tif includeDate && ref.Date != \"\" {\n\t\t\tif t, err := parseBaiduDate(ref.Date); err == nil {","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/infrastructure/web_search/baidu.go#L122-L158","documentation":"Deserialization error in BaiduProvider.doSearch: the 200 response body (already limited to 2MB) could not be unmarshaled into baiduSearchResponse. The %w wraps the JSON error, indicating Baidu returned a schema the provider cannot interpret; raised after the non-200 status branch, so it specifically means 'unparseable success response'.","triggerScenarios":"Thrown at internal/infrastructure/web_search/baidu.go:140 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Log the raw body to see what was actually returned","Check for Baidu API schema changes and update the response structs","Retry once; a truncated body can be transient"],"exampleFix":null,"handlingStrategy":"retry","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"}