{"record":{"id":"0fcccd5b16e1ee63","repo":"grafana/k6","slug":"aggregation-period-is-not-allowed-to-be-zero","errorCode":null,"errorMessage":"aggregation period is not allowed to be zero","messagePattern":"aggregation period is not allowed to be zero","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"output/cloud/expv2/collect.go","lineNumber":67,"sourceCode":"\ntype collector struct {\n\tbq      bucketQ\n\tnowFunc func() time.Time\n\n\taggregationPeriod time.Duration\n\twaitPeriod        time.Duration\n\n\t// we should no longer have to handle metrics that have times long in the past. So instead of a\n\t// map, we can probably use a simple slice (or even an array!) as a ring buffer to store the\n\t// aggregation buckets. This should save us a some time, since it would make the lookups and WaitPeriod\n\t// checks basically O(1). And even if for some reason there are occasional metrics with past times that\n\t// don't fit in the chosen ring buffer size, we could just send them along to the buffer unaggregated\n\ttimeBuckets map[int64]map[metrics.TimeSeries]metricValue\n}\n\nfunc newCollector(aggrPeriod, waitPeriod time.Duration) (*collector, error) {\n\tif aggrPeriod == 0 {\n\t\treturn nil, errors.New(\"aggregation period is not allowed to be zero\")\n\t}\n\tif aggrPeriod != aggrPeriod.Truncate(time.Second) {\n\t\treturn nil, errors.New(\"aggregation period is not allowed to have sub-second precision\")\n\t}\n\tif waitPeriod == 0 {\n\t\t// TODO: we could simplify the expiring logic\n\t\t// just having an internal static logic.\n\t\t// Like skip only not closed buckets bucketEnd > now.\n\t\treturn nil, errors.New(\"aggregation wait period is not allowed to be zero\")\n\t}\n\tif waitPeriod != waitPeriod.Truncate(time.Second) {\n\t\treturn nil, errors.New(\"aggregation wait period is not allowed to have sub-second precision\")\n\t}\n\treturn &collector{\n\t\tbq:                bucketQ{},\n\t\tnowFunc:           time.Now,\n\t\ttimeBuckets:       make(map[int64]map[metrics.TimeSeries]metricValue),\n\t\taggregationPeriod: aggrPeriod,","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/output/cloud/expv2/collect.go#L49-L85","documentation":"Configuration guard in newCollector (cloud output): the metric aggregation period was 0. The collector buckets samples by whole time periods, so a zero period is rejected when the output starts.","triggerScenarios":"Thrown at output/cloud/expv2/collect.go:67 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set K6_CLOUD_API_METRIC_PUSH_INTERVAL_AGGREGATION to a non-zero whole-second duration","Use a positive aggregation period such as '10s' in the cloud output configuration"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}