Tencent/WeKnora · error
http marshal read request: %w
Error message
http marshal read request: %w
What it means
Serialization error in HTTPDocumentReader.Read: marshaling the httpReadRequest payload (file metadata, base64 content, parser config) to JSON failed. The %w wraps encoding/json's error; it fires before any request is built or sent, indicating the request struct could not be serialized (e.g., unsupported field type).
Source
Thrown at internal/infrastructure/docparser/http_parser.go:222
body := httpReadRequest{
FileName: req.FileName,
FileType: req.FileType,
URL: req.URL,
Title: req.Title,
RequestID: req.RequestID,
Config: &httpReadConfig{
ParserEngine: req.ParserEngine,
ParserEngineOverrides: req.ParserEngineOverrides,
},
}
if len(req.FileContent) > 0 {
body.FileContent = base64.StdEncoding.EncodeToString(req.FileContent)
}
jsonBody, err := json.Marshal(body)
if err != nil {
return nil, fmt.Errorf("http marshal read request: %w", err)
}
httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, base+PathRead, bytes.NewReader(jsonBody))
if err != nil {
return nil, fmt.Errorf("http new request: %w", err)
}
httpReq.Header.Set("Content-Type", "application/json")
httpReq.ContentLength = int64(len(jsonBody))
resp, err := p.client.Do(httpReq)
if err != nil {
return nil, fmt.Errorf("http read failed: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
bodyBytes, _ := io.ReadAll(resp.Body)
return nil, fmt.Errorf("http read status %d: %s", resp.StatusCode, string(bodyBytes))
}
var out httpReadResponseView on GitHub (pinned to 988cbb0330)
Solutions
- Check ReadRequest fields for unsupported types
- Ensure config overrides are serializable
- Log the marshal error for the offending field
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at internal/infrastructure/docparser/http_parser.go:222 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/bafdd110003085f3.
Report an issue: GitHub.