cilium/cilium · error
failed to marshal status to JSON
Error message
failed to marshal status to JSON
What it means
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.
Source
Thrown at cilium-cli/clustermesh/clustermesh.go:884
s.KVStoreMesh.Enabled, err = k.kvstoremeshEnabled(ctx)
if err != nil {
return nil, err
}
status := "disabled"
if s.KVStoreMesh.Enabled {
status = "enabled"
}
k.Log("ℹ️ KVStoreMesh is %s", status)
}
s.Connectivity, s.KVStoreMesh.Status, err = k.statusConnectivity(ctx, s.KVStoreMesh.Enabled)
if k.params.Output == status.OutputJSON {
jsonStatus, err := json.MarshalIndent(s, "", " ")
if err != nil {
return nil, fmt.Errorf("failed to marshal status to JSON")
}
fmt.Println(string(jsonStatus))
return s, nil
}
if s.Connectivity != nil {
k.outputConnectivityStatus(s.Connectivity, s.KVStoreMesh.Status, s.KVStoreMesh.Enabled)
}
return s, err
}
func (k *K8sClusterMesh) outputConnectivityStatus(agents, kvstoremesh *ConnectivityStatus, kvstoremeshEnabled bool) {
outputStatusReady := func(status *ConnectivityStatus, component string) {
if status.NotReady > 0 {
k.Log("⚠️ %d/%d %s are not connected to all clusters [min:%d / avg:%.1f / max:%d]",
status.NotReady,
status.Total,View on GitHub (pinned to ac7b90affa)
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
Defensive patterns
Strategy: try-catch
Try / catch
s, err := cm.Status(ctx, client)
if err != nil && err.Error() == "failed to marshal status to JSON" {
// fall back to non-JSON output
return fmt.Errorf("json output broken (upgrade cilium-cli): %w", err)
} Prevention
- 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
When it happens
Trigger: params.Output == status.OutputJSON and json.MarshalIndent(s, "", " ") returns a non-nil error during 'cilium clustermesh status -o json'.
Common situations: 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.
Related errors
- error formatting summary: %v error: %w
- dump constants: %w
- failed to parse restored endpoint: %w
- json.Marshal(%v) failed: %w
- json marshal failed: %w
AI-assisted analysis of cilium/cilium@ac7b90affa (2026-08-31).
Data as JSON: /api/errors/d0e47b6d22dc74b0.
Report an issue: GitHub.