Tencent/WeKnora · error

http read status %d: %s

Error message

http read status %d: %s

What it means

Fired in Read when the WeKnoraCloud /reader endpoint answered with a status other than 202/200. The response body is included in the message, so it usually points to an auth/signature rejection (401/403), a bad request payload (400), or a server-side failure (5xx).

Source

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

	if err != nil {
		logger.Errorf(context.Background(), "[WeKnoraCloud] marshal read request: %v", err)
		return nil, fmt.Errorf("http marshal read request: %w", err)
	}
	httpReq, err := p.newSignedRequest(ctx, http.MethodPost, weKnoraCloudReaderBaseURL+"/reader", jsonBody)
	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"`

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Read the embedded response body for the server's error detail
  2. On 401/403 verify signing credentials and clock skew
  3. On 400 validate FileName/FileType/ParserEngine and URL format
  4. On 5xx retry with backoff; on 4xx fix the request, do not retry
Defensive patterns

Strategy: fallback

When it happens

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