{"record":{"id":"099f7c3f2a182319","repo":"GoogleContainerTools/skaffold","slug":"failed-to-marshal-metricdata","errorCode":null,"errorMessage":"failed to marshal metricdata","messagePattern":"failed to marshal metricdata","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/skaffold/instrumentation/firelog/exporter.go","lineNumber":168,"sourceCode":"\t\tLogEvent: LogEvent{\n\t\t\tEventTimeMS:                  startTimeMS,\n\t\t\tSourceExtensionJSONProto3Str: proto,\n\t\t},\n\t\tRequestTimeMS: startTimeMS,\n\t}\n}\n\nfunc buildProtoStr(name string, kvs EventMetadata) (string, error) {\n\tproto3 := SourceExtensionJSONProto3{\n\t\tConsoleType:     \"SKAFFOLD\",\n\t\tClientInstallID: GetClientInstallID(),\n\t\tEventName:       name,\n\t\tEventMetadata:   kvs,\n\t}\n\n\tb, err := Marshal(proto3)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to marshal metricdata\")\n\t}\n\treturn string(b), nil\n}\n\nfunc toEventMetadata(attributes attribute.Set) EventMetadata {\n\tkvs := EventMetadata{}\n\titerator := attributes.Iter()\n\tfor iterator.Next() {\n\t\tattr := iterator.Attribute()\n\t\tkv := KeyValue{\n\t\t\tKey:   string(attr.Key),\n\t\t\tValue: attr.Value.Emit(),\n\t\t}\n\t\tkvs = append(kvs, kv)\n\t}\n\treturn kvs\n}\n","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/instrumentation/firelog/exporter.go#L150-L186","documentation":"buildProtoStr converts the collected metricdata into a log-entry proto via the firelog Marshal function. If marshaling fails it returns the fixed error \"failed to marshal metricdata\" (note: it drops the underlying error). The data point cannot be sent because the payload could not be encoded.","triggerScenarios":"Metrics export where proto3 marshaling of the constructed log entry (EventName, EventMetadata from the attribute set) fails — e.g. unexpected field types or values in metric attributes.","commonSituations":"Metric attributes containing values that cannot be encoded into the firelog proto; internal incompatibility between the collected metric schema and the encoder.","solutions":["Disable metrics collection to skip export entirely: `skaffold config set --global collect-metrics false`.","Upgrade skaffold — this indicates an internal encoding issue fixed in newer releases.","Report the issue with the skaffold version and command being run, since the underlying marshal error is swallowed."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := exportMetrics(ctx, path, meter); err != nil {\n    if strings.Contains(err.Error(), \"failed to marshal metricdata\") {\n        // log and skip this data point; do not fail the command\n    }\n}","preventionTips":["Keep metric attribute values to proto-encodable types","Upgrade skaffold to get encoder fixes","Disable metrics collection if telemetry encoding keeps failing"],"tags":["telemetry","serialization","proto"],"backgroundTag":"proto-marshal-failed","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}