{"record":{"id":"8cf1c8503ff53f21","repo":"Tencent/WeKnora","slug":"http-read-failed-w-8cf1c8","errorCode":null,"errorMessage":"http read failed: %w","messagePattern":"http read failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/infrastructure/docparser/weknoracloud_http_reader.go","lineNumber":100,"sourceCode":"\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\n\tif err := json.NewDecoder(resp.Body).Decode(&submit); err != nil {\n\t\tlogger.Errorf(context.Background(), \"[WeKnoraCloud] decode read submit response: %v\", err)\n\t\treturn nil, fmt.Errorf(\"http decode read submit response: %w\", err)\n\t}\n\tif strings.TrimSpace(submit.TaskID) == \"\" {\n\t\tlogger.Errorf(context.Background(), \"[WeKnoraCloud] submit response missing task_id (status=%q message=%q)\", submit.Status, submit.Message)\n\t\treturn nil, fmt.Errorf(\"weknoracloud docreader submit response missing task_id\")\n\t}\n\tlogger.Infof(ctx, \"[WeKnoraCloud] task submitted task_id=%s file=%q type=%q\", submit.TaskID, req.FileName, req.FileType)\n\treturn p.pollTaskResult(ctx, submit.TaskID)","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/infrastructure/docparser/weknoracloud_http_reader.go#L82-L118","documentation":"Fired in Read when the signed POST to the WeKnoraCloud /reader endpoint fails at the transport level (p.client.Do returned an error): network outage, DNS failure, TLS problem, or the context was cancelled/timed out. No response was received, so the read task was never submitted.","triggerScenarios":"Thrown at internal/infrastructure/docparser/weknoracloud_http_reader.go:100 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check connectivity to the WeKnoraCloud service endpoint","Inspect the wrapped error for timeout vs connection-refused vs TLS causes","Retry with backoff; transport errors are often transient","If context deadline exceeded, increase the caller's timeout or pollTimeout"],"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"}