{"record":{"id":"e0e3e4d5ecf8566c","repo":"weaviate/weaviate","slug":"failed-to-parse-ner-response-status-d-w","errorCode":null,"errorMessage":"failed to parse NER response (status %d): %w","messagePattern":"failed to parse NER response \\(status (.+?)\\): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/ner-transformers/clients/ner.go","lineNumber":92,"sourceCode":"\t\tbytes.NewReader(body))\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"create POST request\")\n\t}\n\n\tres, err := n.httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"send POST request\")\n\t}\n\tdefer res.Body.Close()\n\n\tbodyBytes, err := io.ReadAll(res.Body)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"read response body\")\n\t}\n\n\tvar resBody nerResponse\n\tif err := json.Unmarshal(bodyBytes, &resBody); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse NER response (status %d): %w\", res.StatusCode, err)\n\t}\n\n\tif res.StatusCode > 399 {\n\t\treturn nil, errors.Errorf(\"fail with status %d: %s\", res.StatusCode, resBody.Error)\n\t}\n\n\tout := make([]ent.TokenResult, len(resBody.Tokens))\n\n\tfor i, elem := range resBody.Tokens {\n\t\tout[i].Certainty = elem.Certainty\n\t\tout[i].Distance = elem.Distance\n\t\tout[i].Entity = elem.Entity\n\t\tout[i].Word = elem.Word\n\t\tout[i].StartPosition = elem.StartPosition\n\t\tout[i].EndPosition = elem.EndPosition\n\t\tout[i].Property = property\n\t}\n","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/modules/ner-transformers/clients/ner.go#L74-L110","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"ct := resp.Header.Get(\"Content-Type\")\nif !strings.Contains(ct, \"application/json\") {\n  return fmt.Errorf(\"NER endpoint returned non-JSON (%s) — check inference URL\", ct)\n}\nif len(bodyBytes) == 0 {\n  return errors.New(\"NER endpoint returned empty body\")\n}","typeGuard":"func isValidNERResponse(b []byte) bool {\n  var probe struct {\n    Tokens []struct {\n      Entity   string  `json:\"entity\"`\n      Word     string  `json:\"word\"`\n      Property string  `json:\"property\"`\n      Certainty float64 `json:\"certainty\"`\n    } `json:\"tokens\"`\n  }\n  return json.Unmarshal(b, &probe) == nil\n}","tryCatchPattern":"tokens, err := nerClient.GetTokens(ctx, text)\nif err != nil {\n  var syntaxErr *json.SyntaxError\n  if errors.As(err, &syntaxErr) {\n    // truncated/invalid body — inspect the NER inference container\n  }\n  return fmt.Errorf(\"NER unavailable: %w\", err)\n}","preventionTips":["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"],"tags":["json","http","ner","inference"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}