Tencent/WeKnora · error

http decode list-engines response: %w

Error message

http decode list-engines response: %w

What it means

Decoding the docreader list-engines JSON response into httpListEnginesResponse failed in ListEngines — the server returned 200 with a body that is not the expected JSON shape (proxy HTML, truncated body, version mismatch).

Source

Thrown at internal/infrastructure/docparser/http_parser.go:161

	httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, base+PathListEngines, bytes.NewReader(jsonBody))
	if err != nil {
		return nil, fmt.Errorf("http new request: %w", err)
	}
	httpReq.Header.Set("Content-Type", "application/json")

	resp, err := p.client.Do(httpReq)
	if err != nil {
		return nil, fmt.Errorf("http list-engines failed: %w", err)
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusOK {
		respBytes, _ := io.ReadAll(resp.Body)
		return nil, fmt.Errorf("http list-engines status %d: %s", resp.StatusCode, string(respBytes))
	}

	var out httpListEnginesResponse
	if err := json.NewDecoder(resp.Body).Decode(&out); err != nil {
		return nil, fmt.Errorf("http decode list-engines response: %w", err)
	}

	result := make([]types.ParserEngineInfo, 0, len(out.Engines))
	for _, e := range out.Engines {
		result = append(result, types.ParserEngineInfo{
			Name:              e.Name,
			Description:       e.Description,
			FileTypes:         e.FileTypes,
			Available:         e.Available,
			UnavailableReason: e.UnavailableReason,
		})
	}
	return result, nil
}

func fromHTTPReadResponse(resp *httpReadResponse) *types.ReadResult {
	result := &types.ReadResult{
		MarkdownContent: resp.MarkdownContent,

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Log a body snippet to see what was actually returned
  2. Check for proxies/interceptors altering responses
  3. Verify client and docreader API versions match
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/infrastructure/docparser/http_parser.go:161 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/894d6b3eac0bde20. Report an issue: GitHub.