{"record":{"id":"d0e47b6d22dc74b0","repo":"cilium/cilium","slug":"failed-to-marshal-status-to-json","errorCode":null,"errorMessage":"failed to marshal status to JSON","messagePattern":"failed to marshal status to JSON","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cilium-cli/clustermesh/clustermesh.go","lineNumber":884,"sourceCode":"\n\t\ts.KVStoreMesh.Enabled, err = k.kvstoremeshEnabled(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tstatus := \"disabled\"\n\t\tif s.KVStoreMesh.Enabled {\n\t\t\tstatus = \"enabled\"\n\t\t}\n\t\tk.Log(\"ℹ️  KVStoreMesh is %s\", status)\n\t}\n\n\ts.Connectivity, s.KVStoreMesh.Status, err = k.statusConnectivity(ctx, s.KVStoreMesh.Enabled)\n\n\tif k.params.Output == status.OutputJSON {\n\t\tjsonStatus, err := json.MarshalIndent(s, \"\", \" \")\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to marshal status to JSON\")\n\t\t}\n\t\tfmt.Println(string(jsonStatus))\n\t\treturn s, nil\n\t}\n\n\tif s.Connectivity != nil {\n\t\tk.outputConnectivityStatus(s.Connectivity, s.KVStoreMesh.Status, s.KVStoreMesh.Enabled)\n\t}\n\n\treturn s, err\n}\n\nfunc (k *K8sClusterMesh) outputConnectivityStatus(agents, kvstoremesh *ConnectivityStatus, kvstoremeshEnabled bool) {\n\toutputStatusReady := func(status *ConnectivityStatus, component string) {\n\t\tif status.NotReady > 0 {\n\t\t\tk.Log(\"⚠️  %d/%d %s are not connected to all clusters [min:%d / avg:%.1f / max:%d]\",\n\t\t\t\tstatus.NotReady,\n\t\t\t\tstatus.Total,","sourceCodeStart":866,"sourceCodeEnd":902,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/cilium-cli/clustermesh/clustermesh.go#L866-L902","documentation":"When the requested output format is JSON, Status marshals the aggregated status struct with json.MarshalIndent. This error means that marshaling failed — which for this struct essentially only happens with unsupported types (e.g. channels, funcs) embedded in the status or an internal marshaling bug. The error message deliberately omits the underlying reason.","triggerScenarios":"params.Output == status.OutputJSON and json.MarshalIndent(s, \"\", \" \") returns a non-nil error during 'cilium clustermesh status -o json'.","commonSituations":"A newly added field in the status struct with an unmarshalable type; version mismatch between cilium-cli binary and its vendored status types; custom output piping expecting JSON on a binary that hit this bug.","solutions":["Upgrade cilium-cli to the latest patch release (this indicates a code-level bug)","File a bug report with the command and versions used if reproducible","As a workaround, use the default (table) output and parse that instead"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"s, err := cm.Status(ctx, client)\nif err != nil && err.Error() == \"failed to marshal status to JSON\" {\n    // fall back to non-JSON output\n    return fmt.Errorf(\"json output broken (upgrade cilium-cli): %w\", err)\n}","preventionTips":["Pin a recent cilium-cli version; this is a code bug, not user error","Test -o json output after upgrading cilium-cli before relying on it in pipelines","Report reproductions to cilium/cilium with versions attached"],"tags":["json","serialization","cilium","bug"],"backgroundTag":"json-marshal-failed","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}