weaviate/weaviate · error
failed to parse NER response (status %d): %w
Error message
failed to parse NER response (status %d): %w
What it means
The ner-transformers client's GetTokens reads the inference container's response and unmarshals it into nerResponse; a malformed body raises this error wrapped with the HTTP status code. Like the other vectorizer clients, parse failure is checked before the status-code check, so a bad body is reported even on error statuses.
Source
Thrown at modules/ner-transformers/clients/ner.go:92
bytes.NewReader(body))
if err != nil {
return nil, errors.Wrap(err, "create POST request")
}
res, err := n.httpClient.Do(req)
if err != nil {
return nil, errors.Wrap(err, "send POST request")
}
defer res.Body.Close()
bodyBytes, err := io.ReadAll(res.Body)
if err != nil {
return nil, errors.Wrap(err, "read response body")
}
var resBody nerResponse
if err := json.Unmarshal(bodyBytes, &resBody); err != nil {
return nil, fmt.Errorf("failed to parse NER response (status %d): %w", res.StatusCode, err)
}
if res.StatusCode > 399 {
return nil, errors.Errorf("fail with status %d: %s", res.StatusCode, resBody.Error)
}
out := make([]ent.TokenResult, len(resBody.Tokens))
for i, elem := range resBody.Tokens {
out[i].Certainty = elem.Certainty
out[i].Distance = elem.Distance
out[i].Entity = elem.Entity
out[i].Word = elem.Word
out[i].StartPosition = elem.StartPosition
out[i].EndPosition = elem.EndPosition
out[i].Property = property
}
View on GitHub (pinned to 75aa4b6d11)
Solutions
- Verify the inference URL points at the ner-transformers inference container (curl it and confirm JSON output)
- Inspect the wrapped %w error for the exact JSON decode failure
- Check the inference container logs for crashes or startup failure
- Pin matching versions of the weaviate module and the NER inference container
Defensive patterns
Strategy: try-catch
Validate before calling
ct := resp.Header.Get("Content-Type")
if !strings.Contains(ct, "application/json") {
return fmt.Errorf("NER endpoint returned non-JSON (%s) — check inference URL", ct)
}
if len(bodyBytes) == 0 {
return errors.New("NER endpoint returned empty body")
} Type guard
func isValidNERResponse(b []byte) bool {
var probe struct {
Tokens []struct {
Entity string `json:"entity"`
Word string `json:"word"`
Property string `json:"property"`
Certainty float64 `json:"certainty"`
} `json:"tokens"`
}
return json.Unmarshal(b, &probe) == nil
} Try / catch
tokens, err := nerClient.GetTokens(ctx, text)
if err != nil {
var syntaxErr *json.SyntaxError
if errors.As(err, &syntaxErr) {
// truncated/invalid body — inspect the NER inference container
}
return fmt.Errorf("NER unavailable: %w", err)
} Prevention
- Point the NER inference URL directly at the inference container
- Health-check the container before running queries
- Keep module and inference-container versions in sync
- Alert on empty/non-JSON responses from the inference endpoint
When it happens
Trigger: The NER inference container returns a body that fails json.Unmarshal — an HTML/proxy error page, empty or truncated body, or a response schema mismatch (e.g. different field names for tokens).
Common situations: ner-transformers inference container misconfigured or crashed; wrong NER_INFERENCE_URL / TRANSFORMERS_INFERENCE_URL pointing at a proxy or wrong service; module and inference container version mismatch after upgrade.
Understand the failure class
Background: "failed to unmarshal" / json.Unmarshal errors: why parsing a response into a Go struct fails and how to fix it — this error's family across 23 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- failed to parse vectorization response (status %d): %w
- unmarshal response: %w
- decode response: %w
- unmarshal status response: %w
- decode async-checkpoint status: %w
AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04).
Data as JSON: /api/errors/e0e3e4d5ecf8566c.
Report an issue: GitHub.