Tencent/WeKnora · error

http poll task failed: %w

Error message

http poll task failed: %w

What it means

Fired in pollTaskResult when the signed GET of the task status URL fails at transport level (client.Do error): network interruption, DNS, TLS, or the poll context deadline expired. The polling loop aborts immediately rather than retrying this iteration.

Source

Thrown at internal/infrastructure/docparser/weknoracloud_http_reader.go:157

func (p *WeKnoraCloudSignedDocumentReader) pollTaskResult(ctx context.Context, taskID string) (*types.ReadResult, error) {
	pollCtx := ctx
	if _, ok := ctx.Deadline(); !ok && p.pollTimeout > 0 {
		var cancel context.CancelFunc
		pollCtx, cancel = context.WithTimeout(ctx, p.pollTimeout)
		defer cancel()
	}
	statusURL := weKnoraCloudReaderBaseURL + "/" + taskID
	currentInterval := p.initialPollInterval
	for {
		httpReq, err := p.newSignedRequest(pollCtx, http.MethodGet, statusURL, nil)
		if err != nil {
			logger.Errorf(context.Background(), "[WeKnoraCloud] poll signed request task_id=%s: %v", taskID, err)
			return nil, err
		}
		resp, err := p.client.Do(httpReq)
		if err != nil {
			logger.Errorf(context.Background(), "[WeKnoraCloud] http poll task_id=%s failed: %v", taskID, err)
			return nil, fmt.Errorf("http poll task failed: %w", err)
		}
		var taskResp weKnoraCloudAsyncTaskResponse
		func() {
			defer resp.Body.Close()
			if resp.StatusCode != http.StatusOK {
				bodyBytes, _ := io.ReadAll(resp.Body)
				err = fmt.Errorf("http poll task status %d: %s", resp.StatusCode, string(bodyBytes))
				logger.Errorf(context.Background(), "[WeKnoraCloud] poll task_id=%s status %d: %s", taskID, resp.StatusCode, string(bodyBytes))
				return
			}
			if decodeErr := json.NewDecoder(resp.Body).Decode(&taskResp); decodeErr != nil {
				err = fmt.Errorf("http decode task response: %w", decodeErr)
				logger.Errorf(context.Background(), "[WeKnoraCloud] poll task_id=%s decode response: %v", taskID, decodeErr)
			}
		}()
		if err != nil {
			return nil, err
		}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Check connectivity to the WeKnoraCloud status endpoint
  2. Inspect the wrapped error for timeout vs connection causes
  3. If the poll context deadline expired, raise pollTimeout or the caller's deadline
  4. Retry the whole poll/read operation; the task may still complete server-side
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/infrastructure/docparser/weknoracloud_http_reader.go:157 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/4c55e9f47db20e8e. Report an issue: GitHub.