{"record":{"id":"24df9cfe13bdcbd5","repo":"grafana/k6","slug":"the-protobuf-message-is-too-large-to-be-handled-by-24df9c","errorCode":null,"errorMessage":"the Protobuf message is too large to be handled by Snappy encoder; size: %d, limit: %d","messagePattern":"the Protobuf message is too large to be handled by Snappy encoder; size: (.+?), limit: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"output/cloud/expv2/metrics_client.go","lineNumber":103,"sourceCode":"\terr = mc.httpClient.Do(req, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\nfunc newRequestBody(data *pbcloud.MetricSet) ([]byte, error) {\n\tb, err := proto.Marshal(data)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"encoding metrics as Protobuf write request failed: %w\", err)\n\t}\n\t// TODO: use the framing format\n\t// https://github.com/google/snappy/blob/main/framing_format.txt\n\t// It can be done replacing the encode with\n\t// https://pkg.go.dev/github.com/klauspost/compress/snappy#NewBufferedWriter\n\tif snappy.MaxEncodedLen(len(b)) < 0 {\n\t\treturn nil, fmt.Errorf(\"the Protobuf message is too large to be handled by Snappy encoder; \"+\n\t\t\t\"size: %d, limit: %d\", len(b), 0xffffffff)\n\t}\n\treturn snappy.Encode(nil, b), nil\n}\n","sourceCodeStart":85,"sourceCodeEnd":108,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/output/cloud/expv2/metrics_client.go#L85-L108","documentation":"In newRequestBody, snappy.MaxEncodedLen returned a negative value for the marshalled Protobuf message, meaning the message exceeds the maximum size the Snappy encoder can handle (~2GB). A single batched MetricSet payload grew beyond the encoder's representable limit.","triggerScenarios":"Thrown at output/cloud/expv2/metrics_client.go:103 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce the volume of metrics emitted per aggregation window (fewer tags, fewer custom metrics)","Shorten the aggregation period so batches stay small","Report to grafana/k6 — the client should split oversized payloads rather than fail"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}