{"record":{"id":"4d9886f04545a5b3","repo":"Tencent/WeKnora","slug":"poll-error-code-d-msg-s","errorCode":null,"errorMessage":"poll error code=%d msg=%s","messagePattern":"poll error code=(.+?) msg=(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/infrastructure/docparser/mineru_cloud_converter.go","lineNumber":291,"sourceCode":"\n\tclient := utils.NewSSRFSafeHTTPClient(utils.SSRFSafeHTTPClientConfig{Timeout: 30 * time.Second, MaxRedirects: 5})\n\tresp, err := client.Do(httpReq)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"read poll response body: %w\", err)\n\t}\n\n\tvar pollResp batchPollResponse\n\tif err := json.Unmarshal(respBody, &pollResp); err != nil {\n\t\treturn nil, fmt.Errorf(\"decode poll response: %w\", err)\n\t}\n\tif pollResp.Code != 0 {\n\t\treturn nil, fmt.Errorf(\"poll error code=%d msg=%s\", pollResp.Code, pollResp.Msg)\n\t}\n\n\tif len(pollResp.Data.ExtractResult) == 0 {\n\t\treturn nil, nil\n\t}\n\n\t// Dump the raw extract_result JSON for debugging\n\trawExtract := string(pollResp.Data.ExtractResult)\n\tif len(rawExtract) > 4000 {\n\t\tlogger.Infof(context.Background(), \"[MinerUCloud] Raw extract_result (truncated to 4000 chars): %s ...\", rawExtract[:4000])\n\t} else {\n\t\tlogger.Infof(context.Background(), \"[MinerUCloud] Raw extract_result: %s\", rawExtract)\n\t}\n\n\t// Pretty-print the structure to reveal all available fields\n\tvar rawObj interface{}\n\tif err := json.Unmarshal(pollResp.Data.ExtractResult, &rawObj); err == nil {\n\t\tlogResponseStructure(\"MinerUCloud\", rawObj, \"extract_result\")","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/infrastructure/docparser/mineru_cloud_converter.go#L273-L309","documentation":"MinerU Cloud returned a well-formed poll response but with a non-zero business error code; fetchBatchStatus rejects it with 'poll error code=%d msg=%s' (mineru_cloud_converter.go:291). This is the API's application-level error signaling (in pollResp.Code / pollResp.Msg), e.g. the batch task ID is unknown or the task failed server-side. It is not a transport or JSON problem — the HTTP call and decode succeeded.","triggerScenarios":"pollBatchResult -> fetchBatchStatus polls a batch ID that the MinerU Cloud service does not recognize, that has expired (results retention window passed), or that failed server-side; the response body contains code != 0.","commonSituations":"Polling after the batch results were purged (task finished long ago); a typo'd or reused batch ID; submitting with one API key and polling with another tenant's; MinerU Cloud service outage reporting an internal error code.","solutions":["Read the msg value in the error — it names the server-side cause (e.g. task not found, task failed).","Verify the batch ID being polled was obtained from the successful upload/create-batch response in the same session/key.","Poll promptly: results may expire; re-submit the document if the task is gone.","Check MinerU Cloud status/announcements if the code indicates a service-side failure."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isPollBusinessError(err error) bool {\n    return err != nil && strings.HasPrefix(err.Error(), \"poll error code=\")\n}","tryCatchPattern":"items, err := pollBatchResult(ctx, batchID)\nif err != nil {\n    var apiErr *MinerUPollError\n    if errors.As(err, &apiErr) && apiErr.Code == errCodeTaskNotFound {\n        // batch expired/unknown: re-submit the document\n        return resubmitBatch(ctx, doc)\n    }\n    return err\n}","preventionTips":["Parse the code/msg out of the error message to branch on task-not-found vs task-failed.","Poll promptly after submission; results can expire server-side.","Use the same API key/tenant for create-batch and poll calls."],"tags":["api-error","http","polling","go","cloud-service"],"backgroundTag":"api-error-code-response","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}