{"record":{"id":"b71105328da7672c","repo":"netbirdio/netbird","slug":"error-marshaling-sync-response","errorCode":null,"errorMessage":"Error marshaling sync response: {}","messagePattern":"Error marshaling sync response: (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"proxy/internal/debug/handler.go","lineNumber":527,"sourceCode":"\t\thttp.Error(w, \"Error getting sync response: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tif syncResp == nil {\n\t\thttp.Error(w, \"No sync response available for client: \"+string(accountID), http.StatusNotFound)\n\t\treturn\n\t}\n\n\topts := protojson.MarshalOptions{\n\t\tEmitUnpopulated: true,\n\t\tUseProtoNames:   true,\n\t\tIndent:          \"  \",\n\t\tAllowPartial:    true,\n\t}\n\n\tjsonBytes, err := opts.Marshal(syncResp)\n\tif err != nil {\n\t\thttp.Error(w, \"Error marshaling sync response: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tif wantJSON {\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\t_, _ = w.Write(jsonBytes)\n\t\treturn\n\t}\n\n\tdata := clientDetailData{\n\t\tAccountID: string(accountID),\n\t\tActiveTab: \"syncresponse\",\n\t\tContent:   string(jsonBytes),\n\t}\n\n\th.renderTemplate(w, \"clientDetail\", data)\n}\n","sourceCodeStart":509,"sourceCodeEnd":545,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/proxy/internal/debug/handler.go#L509-L545","documentation":"Fires in handleClientSyncResponse when protojson.MarshalOptions.Marshal fails to serialize the stored sync response to indented JSON. The response exists, but its protobuf content cannot be marshaled — typically an invalid or inconsistently populated message, or a field that violates protojson constraints. Rare, since sync responses come from generated protobuf types.","triggerScenarios":"Thrown at proxy/internal/debug/handler.go:527 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read the wrapped error for which message/field protojson rejected","Check the client's stored sync response for corruption or unexpected content","Verify the sync response proto version matches what the proxy build expects","Force a fresh sync by restarting the client so a valid response replaces the malformed one"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","contentChangedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}