{"record":{"id":"6440c8b95293eca2","repo":"JuliusBrussee/caveman","slug":"cachebench-request-q-needs-s-or-s-for-reconstr","errorCode":null,"errorMessage":"cachebench: request %q needs %s or %s for reconstruction","messagePattern":"cachebench: request %q needs (.+?) or (.+?) for reconstruction","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/trace.go","lineNumber":352,"sourceCode":"\t\tseen[record.RequestID] = true\n\t\trecord.Body = append(json.RawMessage(nil), record.Body...)\n\t\trecords = append(records, record)\n\t}\n\tif err := scanner.Err(); err != nil {\n\t\treturn nil, fmt.Errorf(\"cachebench: read trace: %w\", err)\n\t}\n\tif len(records) == 0 {\n\t\treturn nil, errors.New(\"cachebench: no trace records\")\n\t}\n\treturn records, nil\n}\n\n// NativeRequest reconstructs exact optimizer input captured by v2 or v3 trace.\n// Legacy v1 traces remain readable for observation joins, but cannot drive live\n// replay because they omitted routing and economics inputs.\nfunc (record TraceRecord) NativeRequest() (cacheengine.NativeRequest, error) {\n\tif record.Schema != TraceSchema && record.Schema != TraceSchemaV2 {\n\t\treturn cacheengine.NativeRequest{}, fmt.Errorf(\"cachebench: request %q needs %s or %s for reconstruction\", record.RequestID, TraceSchemaV2, TraceSchema)\n\t}\n\tif !validTraceIdentity(record) || !validTimingBasis(record.TimingBasis) || record.ExpectedRPM <= 0 || record.ExpectedCalls <= 0 || record.PrefixTokens < 0 || !validUniqueJSONObject(record.Body) || record.BodySHA256 != bodyDigest(record.Body) || record.StableSegmentCount < 0 || record.StableSegmentCount > len(record.Prefix) || !validPrefix(record.Prefix) {\n\t\treturn cacheengine.NativeRequest{}, fmt.Errorf(\"cachebench: request %q has incomplete or invalid replay identity\", record.RequestID)\n\t}\n\treturn cacheengine.NativeRequest{\n\t\tScope: record.Scope, Epoch: record.Epoch, PartitionKey: record.PartitionKey,\n\t\tExpectedRequestsPerMinute: record.ExpectedRPM, ExpectedCalls: record.ExpectedCalls,\n\t\tProvider: record.Provider, Model: record.Model, Region: record.Region, Endpoint: record.Endpoint,\n\t\tBody: append([]byte(nil), record.Body...), RuntimeMode: record.RuntimeMode, AuthMode: record.AuthMode,\n\t\tPrefixTokens: record.PrefixTokens,\n\t}, nil\n}\n\nfunc validTraceIdentity(record TraceRecord) bool {\n\treturn validBoundedText(record.RequestID, 512, false) &&\n\t\tvalidBoundedText(record.Provider, 64, false) &&\n\t\tvalidBoundedText(record.Model, 512, false) &&\n\t\tvalidBoundedText(record.Region, 64, true) &&","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/cacheengine/cachebench/trace.go#L334-L370","documentation":"Error \"cachebench: request %q needs %s or %s for reconstruction\" thrown in JuliusBrussee/caveman.","triggerScenarios":"Thrown at cacheengine/cachebench/trace.go:352 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide the required reconstruction fields on the request."],"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"}