{"record":{"id":"ec852e2d302c2eb7","repo":"Tencent/WeKnora","slug":"failed-to-read-metaso-response-w","errorCode":null,"errorMessage":"failed to read Metaso response: %w","messagePattern":"failed to read Metaso response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/infrastructure/web_search/metaso.go","lineNumber":146,"sourceCode":"\t\tresult := &types.WebSearchResult{Title: item.Title, URL: item.Link, Snippet: snippet, Content: item.RawContent, Source: \"metaso\"}\n\t\tif includeDate {\n\t\t\tif publishedAt, ok := parseMetasoDate(item.Date); ok {\n\t\t\t\tresult.PublishedAt = &publishedAt\n\t\t\t}\n\t\t}\n\t\tresults = append(results, result)\n\t\tif len(results) >= maxResults {\n\t\t\tbreak\n\t\t}\n\t}\n\tlogger.Infof(ctx, \"[WebSearch][Metaso] returned %d results\", len(results))\n\treturn results, nil\n}\n\nfunc readMetasoResponseBody(reader io.Reader) ([]byte, error) {\n\tbody, err := io.ReadAll(io.LimitReader(reader, maxMetasoResponseBytes+1))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read Metaso response: %w\", err)\n\t}\n\tif len(body) > maxMetasoResponseBytes {\n\t\treturn nil, fmt.Errorf(\"Metaso response exceeds %d bytes\", maxMetasoResponseBytes)\n\t}\n\treturn body, nil\n}\n\nfunc metasoHTTPError(statusCode int, body []byte) error {\n\tvar apiError struct {\n\t\tMessage string `json:\"message\"`\n\t\tError   string `json:\"error\"`\n\t}\n\tif json.Unmarshal(body, &apiError) == nil {\n\t\tdetail := strings.TrimSpace(apiError.Message)\n\t\tif detail == \"\" {\n\t\t\tdetail = strings.TrimSpace(apiError.Error)\n\t\t}\n\t\tif detail != \"\" {","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/infrastructure/web_search/metaso.go#L128-L164","documentation":"I/O error in readMetasoResponseBody: reading the Metaso response stream (capped at maxMetasoResponseBytes+1 via LimitReader) failed before completion. The %w wraps the io error (truncated connection, reset); it fires when the body cannot be fully read, distinct from later size-limit and parse handling.","triggerScenarios":"Thrown at internal/infrastructure/web_search/metaso.go:146 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check network stability to the Metaso endpoint","Retry the search; partial reads are typically 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"}