{"record":{"id":"a4ffd6bf90be9898","repo":"weaviate/weaviate","slug":"object-ttl-marshal-response-err-error","errorCode":null,"errorMessage":"/object ttl marshal response: err.Error()","messagePattern":"/object ttl marshal response: err\\.Error\\(\\)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"warning","filePath":"adapters/handlers/rest/clusterapi/object_ttl.go","lineNumber":106,"sourceCode":"\t\tdefault:\n\t\t\thttp.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)\n\t\t\treturn\n\t\t}\n\t}\n}\n\nfunc (d *ObjectTTL) incomingStatus() http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tdefer r.Body.Close()\n\n\t\tstatus := objectttl.ObjectsExpiredStatusResponse{\n\t\t\tDeletionOngoing: d.localStatus.IsRunning(),\n\t\t}\n\n\t\tstatus.SetContentTypeHeader(w)\n\t\tw.WriteHeader(http.StatusOK)\n\t\tif err := json.NewEncoder(w).Encode(status); err != nil {\n\t\t\thttp.Error(w, \"/object ttl marshal response: \"+err.Error(),\n\t\t\t\thttp.StatusInternalServerError)\n\t\t}\n\t})\n}\n\nfunc (d *ObjectTTL) incomingDelete() http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tdefer r.Body.Close()\n\n\t\tok, ttlCtx := d.localStatus.SetRunning()\n\t\tif !ok {\n\t\t\thttp.Error(w, \"another request is still being processed\", http.StatusTooManyRequests)\n\t\t\treturn\n\t\t}\n\n\t\tvar body []objectttl.ObjectsExpiredPayload\n\t\tif err := json.NewDecoder(r.Body).Decode(&body); err != nil {\n\t\t\td.localStatus.ResetRunning(\"bad request\")","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/handlers/rest/clusterapi/object_ttl.go#L88-L124","documentation":"In `ObjectTTL.incomingStatus`, the handler builds an `ObjectsExpiredStatusResponse` (a single bool field, `DeletionOngoing`) and JSON-encodes it directly into the ResponseWriter. If `json.NewEncoder(w).Encode` fails — typically because the client disconnected before/while the body was written — the handler attempts a second write with a 500 and the message `/object ttl marshal response: <err>`. Because the 200 status and headers were already sent, this error text usually cannot reach the caller and mainly surfaces in server logs.","triggerScenarios":"POST/GET to `/cluster/object_ttl/status` where the peer closes the connection mid-response, a network interruption between cluster nodes, or (rarely) an http.ResponseWriter implementation whose Encode/write path errors, e.g. a wrapped writer with a size-limited buffer.","commonSituations":"Flaky inter-node networking in Kubernetes pods; aggressive client timeouts shorter than the server's response time; node restarts during a rolling upgrade while another node polls TTL status.","solutions":["Retry the status request; a transient write failure on a 2-line JSON body is almost always a connection problem, not a data problem.","Check inter-node connectivity (pod liveness, network policies, keepalive settings) between the calling and responding cluster nodes.","If reproducible with an always-connected client, capture the inner encoder error from server logs — the marshalable struct is trivially serializable, so the fault lies in the transport/writer."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const res = await fetch(statusUrl);\n  const status = await res.json();\n} catch (e) {\n  if (attempt < maxRetries) return retryWithBackoff(attempt + 1);\n  throw e;\n}","preventionTips":["Set client timeouts comfortably above expected cluster RTT.","Expect transient failures on inter-node calls and retry with backoff.","Treat a failed status read as a connectivity signal, not a data error."],"tags":["json","http","serialization","cluster-api"],"backgroundTag":"json-encode-failed","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}