{"record":{"id":"e32d478d0c916062","repo":"grafana/k6","slug":"aggregation-wait-period-is-not-allowed-to-have-sub","errorCode":null,"errorMessage":"aggregation wait period is not allowed to have sub-second precision","messagePattern":"aggregation wait period is not allowed to have sub-second precision","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"output/cloud/expv2/collect.go","lineNumber":79,"sourceCode":"\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,\n\t\twaitPeriod:        waitPeriod,\n\t}, nil\n}\n\n// CollectSamples drain the buffer and collect all the samples.\nfunc (c *collector) CollectSamples(containers []metrics.SampleContainer) {\n\t// Distribute all newly buffered samples into related buckets\n\tfor _, sampleContainer := range containers {\n\t\tsamples := sampleContainer.GetSamples()\n\n\t\tfor i := range samples {\n\t\t\tc.collectSample(samples[i])","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/output/cloud/expv2/collect.go#L61-L97","documentation":"Configuration guard in newCollector: the wait period has sub-second precision (waitPeriod != waitPeriod.Truncate(time.Second)), which the whole-second bucket expiry logic cannot handle.","triggerScenarios":"Thrown at output/cloud/expv2/collect.go:79 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Round the wait period to whole seconds, e.g. '5s' instead of '5.5s'","Set K6_CLOUD_API_METRIC_PUSH_INTERVAL_WAIT to a whole-second value"],"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"}