netbirdio/netbird · error

Error marshaling sync response

Error message

Error marshaling sync response: {}

What it means

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.

Solutions

  1. Read the wrapped error for which message/field protojson rejected
  2. Check the client's stored sync response for corruption or unexpected content
  3. Verify the sync response proto version matches what the proxy build expects
  4. Force a fresh sync by restarting the client so a valid response replaces the malformed one
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at proxy/internal/debug/handler.go:527 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16). Data as JSON: /api/errors/b71105328da7672c. Report an issue: GitHub.

Appendix: source

Thrown at proxy/internal/debug/handler.go:527

		http.Error(w, "Error getting sync response: "+err.Error(), http.StatusInternalServerError)
		return
	}

	if syncResp == nil {
		http.Error(w, "No sync response available for client: "+string(accountID), http.StatusNotFound)
		return
	}

	opts := protojson.MarshalOptions{
		EmitUnpopulated: true,
		UseProtoNames:   true,
		Indent:          "  ",
		AllowPartial:    true,
	}

	jsonBytes, err := opts.Marshal(syncResp)
	if err != nil {
		http.Error(w, "Error marshaling sync response: "+err.Error(), http.StatusInternalServerError)
		return
	}

	if wantJSON {
		w.Header().Set("Content-Type", "application/json")
		_, _ = w.Write(jsonBytes)
		return
	}

	data := clientDetailData{
		AccountID: string(accountID),
		ActiveTab: "syncresponse",
		Content:   string(jsonBytes),
	}

	h.renderTemplate(w, "clientDetail", data)
}

View on GitHub (pinned to 93e97f4bf1)