Tencent/WeKnora · error

http decode read submit response: %w

Error message

http decode read submit response: %w

What it means

Fired in Read when the JSON body of the submit response from WeKnoraCloud /reader cannot be decoded into weKnoraCloudAsyncSubmitResponse. Means the server returned 2xx but a malformed or unexpected payload, or an empty/truncated body.

Source

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

	if err != nil {
		logger.Errorf(context.Background(), "[WeKnoraCloud] signed read request: %v", err)
		return nil, err
	}
	resp, err := p.client.Do(httpReq)
	if err != nil {
		logger.Errorf(context.Background(), "[WeKnoraCloud] http read request failed: %v", err)
		return nil, fmt.Errorf("http read failed: %w", err)
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusAccepted && resp.StatusCode != http.StatusOK {
		bodyBytes, _ := io.ReadAll(resp.Body)
		logger.Errorf(context.Background(), "[WeKnoraCloud] http read unexpected status %d: %s", resp.StatusCode, string(bodyBytes))
		return nil, fmt.Errorf("http read status %d: %s", resp.StatusCode, string(bodyBytes))
	}
	var submit weKnoraCloudAsyncSubmitResponse
	if err := json.NewDecoder(resp.Body).Decode(&submit); err != nil {
		logger.Errorf(context.Background(), "[WeKnoraCloud] decode read submit response: %v", err)
		return nil, fmt.Errorf("http decode read submit response: %w", err)
	}
	if strings.TrimSpace(submit.TaskID) == "" {
		logger.Errorf(context.Background(), "[WeKnoraCloud] submit response missing task_id (status=%q message=%q)", submit.Status, submit.Message)
		return nil, fmt.Errorf("weknoracloud docreader submit response missing task_id")
	}
	logger.Infof(ctx, "[WeKnoraCloud] task submitted task_id=%s file=%q type=%q", submit.TaskID, req.FileName, req.FileType)
	return p.pollTaskResult(ctx, submit.TaskID)
}

type weKnoraCloudAsyncSubmitResponse struct {
	TaskID    string `json:"task_id"`
	Status    string `json:"status"`
	Message   string `json:"message"`
	CreatedAt int64  `json:"created_at"`
}

type weKnoraCloudAsyncTaskResponse struct {
	TaskID    string            `json:"task_id"`

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Log the raw response body to see what the server actually returned
  2. Verify the WeKnoraCloud server version matches the expected API schema
  3. Retry the submission once; a truncated response may be transient
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/infrastructure/docparser/weknoracloud_http_reader.go:111 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/f06cb1db186508f0. Report an issue: GitHub.