{"record":{"id":"daa7158af5a913d1","repo":"JuliusBrussee/caveman","slug":"cachebench-replay-gap-before-q-exceeds-limit-s","errorCode":null,"errorMessage":"cachebench: replay gap before %q exceeds limit %s","messagePattern":"cachebench: replay gap before %q exceeds limit (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/replay.go","lineNumber":409,"sourceCode":"\t\ttiming[record.TimingBasis] = true\n\t\tif limits.RequireProviderTokens && record.TokenBasis != TokenProviderCounted {\n\t\t\treturn ReplayPreflight{}, fmt.Errorf(\"cachebench: replay request %q token basis %q is not provider-counted\", record.RequestID, record.TokenBasis)\n\t\t}\n\t\ttokens[record.TokenBasis] = true\n\t\tif record.DeclaredInputTokens <= 0 || record.DeclaredInputTokens < record.PrefixTokens || record.MaxOutputTokens <= 0 || !requestBudgetMatchesBody(record) {\n\t\t\treturn ReplayPreflight{}, fmt.Errorf(\"cachebench: replay request %q has invalid billed-token budget\", record.RequestID)\n\t\t}\n\t\tinput, output := int64(record.DeclaredInputTokens), int64(record.MaxOutputTokens)\n\t\tif input > limits.MaxDeclaredBilledTokens-worstCase || output > limits.MaxDeclaredBilledTokens-worstCase-input {\n\t\t\treturn ReplayPreflight{}, fmt.Errorf(\"cachebench: replay declared billed-token ceiling exceeds limit %d\", limits.MaxDeclaredBilledTokens)\n\t\t}\n\t\tdeclaredInput += input\n\t\tdeclaredOutput += output\n\t\tworstCase += input + output\n\t\tif !previous.IsZero() {\n\t\t\tgap, err := scaledReplayGap(at.Sub(previous), timeScale)\n\t\t\tif err != nil || gap > limits.MaxGap {\n\t\t\t\treturn ReplayPreflight{}, fmt.Errorf(\"cachebench: replay gap before %q exceeds limit %s\", record.RequestID, limits.MaxGap)\n\t\t\t}\n\t\t\tif int64(gap) > math.MaxInt64-scheduled {\n\t\t\t\treturn ReplayPreflight{}, errors.New(\"cachebench: replay schedule duration overflow\")\n\t\t\t}\n\t\t\tscheduled += int64(gap)\n\t\t}\n\t\tprevious = at\n\t}\n\tbases := make([]string, 0, len(timing))\n\tfor basis := range timing {\n\t\tbases = append(bases, basis)\n\t}\n\tsort.Strings(bases)\n\ttokenBases := make([]string, 0, len(tokens))\n\tfor basis := range tokens {\n\t\ttokenBases = append(tokenBases, basis)\n\t}\n\tsort.Strings(tokenBases)","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/cachebench/replay.go#L391-L427","documentation":"ValidateReplay measures the absolute-time gap between consecutive trace records; the gap before request %q exceeds ReplayLimits.MaxGap. Large gaps would make faithful replay impractically long, so preflight rejects them.","triggerScenarios":"Thrown at cacheengine/cachebench/replay.go:409 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Raise MaxGap or increase TimeScale to compress idle periods","Split the trace at long idle boundaries"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}