{"record":{"id":"ab04ad6961fe4e97","repo":"JuliusBrussee/caveman","slug":"cachebench-replay-request-q-has-invalid-time-ord","errorCode":null,"errorMessage":"cachebench: replay request %q has invalid time order","messagePattern":"cachebench: replay request %q has invalid time order","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/replay.go","lineNumber":386,"sourceCode":"\tseen := make(map[string]bool, len(records))\n\ttiming := map[string]bool{}\n\ttokens := map[string]bool{}\n\tvar previous time.Time\n\tvar declaredInput, declaredOutput, worstCase, scheduled int64\n\tfor index, record := range records {\n\t\tif seen[record.RequestID] {\n\t\t\treturn ReplayPreflight{}, fmt.Errorf(\"cachebench: duplicate replay request %q\", record.RequestID)\n\t\t}\n\t\tseen[record.RequestID] = true\n\t\tif record.Schema != TraceSchema {\n\t\t\treturn ReplayPreflight{}, fmt.Errorf(\"cachebench: replay request %q needs %s billed-token metadata\", record.RequestID, TraceSchema)\n\t\t}\n\t\tif _, err := record.NativeRequest(); err != nil {\n\t\t\treturn ReplayPreflight{}, fmt.Errorf(\"cachebench: replay request %d: %w\", index, err)\n\t\t}\n\t\tat, err := time.Parse(time.RFC3339Nano, record.At)\n\t\tif err != nil || !previous.IsZero() && at.Before(previous) {\n\t\t\treturn ReplayPreflight{}, fmt.Errorf(\"cachebench: replay request %q has invalid time order\", record.RequestID)\n\t\t}\n\t\tif limits.RequireGroundedTiming && record.TimingBasis != TimingGrounded {\n\t\t\treturn ReplayPreflight{}, fmt.Errorf(\"cachebench: replay request %q timing basis %q is not globally grounded\", record.RequestID, record.TimingBasis)\n\t\t}\n\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","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/cachebench/replay.go#L368-L404","documentation":"Ordering guard in ValidateReplay: a record's 'at' timestamp is unparseable as RFC3339Nano or earlier than the previous record's. The trace must be chronologically ordered; the offending record's at field is at fault.","triggerScenarios":"Thrown at cacheengine/cachebench/replay.go:386 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Regenerate the trace with monotonic timestamps","Sort records by At before replay"],"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"}