{"record":{"id":"ba68bc89eccf0fd1","repo":"JuliusBrussee/caveman","slug":"cache-replay-trace-exceeds-d-bytes","errorCode":null,"errorMessage":"cache-replay: trace exceeds %d bytes","messagePattern":"cache-replay: trace exceeds (.+?) bytes","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cmd/cache-replay/main.go","lineNumber":363,"sourceCode":"}\n\nfunc readTrace(path string, maxBytes int64, maxRecords int) ([]cachebench.TraceRecord, string, error) {\n\tfile, err := os.Open(path)\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\tdefer file.Close()\n\thash := sha256.New()\n\tlimited := &io.LimitedReader{R: file, N: maxBytes + 1}\n\treadLimits := cachebench.DefaultTraceReadLimits()\n\treadLimits.MaxLineBytes = int(maxBytes)\n\treadLimits.MaxRecords = maxRecords\n\trecords, err := cachebench.ReadTraceJSONLWithLimits(io.TeeReader(limited, hash), readLimits)\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\tif limited.N <= 0 {\n\t\treturn nil, \"\", fmt.Errorf(\"cache-replay: trace exceeds %d bytes\", maxBytes)\n\t}\n\treturn records, hex.EncodeToString(hash.Sum(nil)), nil\n}\n\nfunc validateProviderCredentials(records []cachebench.TraceRecord) error {\n\tproviders := map[string]bool{}\n\tfor _, record := range records {\n\t\tproviders[record.Provider] = true\n\t}\n\tfor provider := range providers {\n\t\tswitch provider {\n\t\tcase \"openai\":\n\t\t\tif os.Getenv(\"OPENAI_API_KEY\") == \"\" {\n\t\t\t\treturn errors.New(\"cache-replay: OPENAI_API_KEY unavailable\")\n\t\t\t}\n\t\tcase \"anthropic\":\n\t\t\tif os.Getenv(\"ANTHROPIC_API_KEY\") == \"\" {\n\t\t\t\treturn errors.New(\"cache-replay: ANTHROPIC_API_KEY unavailable\")","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/cacheengine/cmd/cache-replay/main.go#L345-L381","documentation":"Error \"cache-replay: trace exceeds %d bytes\" thrown in JuliusBrussee/caveman.","triggerScenarios":"Thrown at cacheengine/cmd/cache-replay/main.go:363 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce the trace below the byte limit."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}