Tencent/WeKnora · error

http new request: %w

Error message

http new request: %w

What it means

HTTP client error in HTTPDocumentReader.ListEngines: building the POST request to the docreader list-engines endpoint (base+PathListEngines) failed at http.NewRequestWithContext. The %w carries the net/http cause; it fires pre-send, after SSRF validation and body marshaling have already succeeded.

Source

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

func (p *HTTPDocumentReader) ListEngines(ctx context.Context, overrides map[string]string) ([]types.ParserEngineInfo, error) {
	base := p.base()
	if base == "" {
		return nil, errNotConnected
	}
	if err := secutils.ValidateURLForSSRF(base); err != nil {
		return nil, fmt.Errorf("docreader address failed SSRF validation: %w", err)
	}

	body := httpListEnginesRequest{ConfigOverrides: overrides}
	jsonBody, err := json.Marshal(body)
	if err != nil {
		return nil, fmt.Errorf("http marshal list-engines request: %w", err)
	}

	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)
	}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Verify the configured docreader HTTP base URL parses
  2. Check the path constants form a valid URL when joined
  3. Log the composed URL to diagnose
Defensive patterns

Strategy: try-catch

When it happens

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