{"record":{"id":"b717bfdb713c7f11","repo":"Tencent/WeKnora","slug":"http-marshal-read-request-w-b717bf","errorCode":null,"errorMessage":"http marshal read request: %w","messagePattern":"http marshal read request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/infrastructure/docparser/weknoracloud_http_reader.go","lineNumber":90,"sourceCode":"\t\treq.FileName, req.FileType, req.ParserEngine, strings.TrimSpace(req.URL) != \"\", len(req.FileContent), req.RequestID)\n\tbody := httpReadRequest{\n\t\tFileName:  req.FileName,\n\t\tFileType:  req.FileType,\n\t\tURL:       req.URL,\n\t\tTitle:     req.Title,\n\t\tRequestID: req.RequestID,\n\t\tConfig: &httpReadConfig{\n\t\t\tParserEngine:          req.ParserEngine,\n\t\t\tParserEngineOverrides: req.ParserEngineOverrides,\n\t\t},\n\t}\n\tif len(req.FileContent) > 0 {\n\t\tbody.FileContent = base64.StdEncoding.EncodeToString(req.FileContent)\n\t}\n\tjsonBody, err := json.Marshal(body)\n\tif err != nil {\n\t\tlogger.Errorf(context.Background(), \"[WeKnoraCloud] marshal read request: %v\", err)\n\t\treturn nil, fmt.Errorf(\"http marshal read request: %w\", err)\n\t}\n\thttpReq, err := p.newSignedRequest(ctx, http.MethodPost, weKnoraCloudReaderBaseURL+\"/reader\", jsonBody)\n\tif err != nil {\n\t\tlogger.Errorf(context.Background(), \"[WeKnoraCloud] signed read request: %v\", err)\n\t\treturn nil, err\n\t}\n\tresp, err := p.client.Do(httpReq)\n\tif err != nil {\n\t\tlogger.Errorf(context.Background(), \"[WeKnoraCloud] http read request failed: %v\", err)\n\t\treturn nil, fmt.Errorf(\"http read failed: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\tif resp.StatusCode != http.StatusAccepted && resp.StatusCode != http.StatusOK {\n\t\tbodyBytes, _ := io.ReadAll(resp.Body)\n\t\tlogger.Errorf(context.Background(), \"[WeKnoraCloud] http read unexpected status %d: %s\", resp.StatusCode, string(bodyBytes))\n\t\treturn nil, fmt.Errorf(\"http read status %d: %s\", resp.StatusCode, string(bodyBytes))\n\t}\n\tvar submit weKnoraCloudAsyncSubmitResponse","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/infrastructure/docparser/weknoracloud_http_reader.go#L72-L108","documentation":"Fired in Read when json.Marshal of the httpReadRequest body fails. The request struct only holds plain strings/byte slices, so this practically fires only if FileContent/base64 encoding yields an unmarshalable value or a custom marshaler errors; it aborts the document read submission before any HTTP call.","triggerScenarios":"Thrown at internal/infrastructure/docparser/weknoracloud_http_reader.go:90 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped error to find which field failed to marshal","Log req.RequestID and FileType to identify the offending document","Retry once with a fresh request; marshal failures here are not transient in practice","Report upstream if a supported FileType produces unmarshalable content"],"exampleFix":null,"handlingStrategy":"try-catch","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"}