JuliusBrussee/caveman · error

cachebench: no trace records

Error message

cachebench: no trace records

What it means

The trace JSONL reader reached EOF (or read only blank input) without accepting any records. A replay needs at least one valid trace record, so an empty stream — wrong file, empty file, or over-aggressive filtering — fails here.

Solutions

  1. Verify the -trace path points to a non-empty JSONL file containing valid records
  2. Check that earlier reading of the same stream did not exhaust it before passing the reader
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cacheengine/cachebench/trace.go:342 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18). Data as JSON: /api/errors/8e840a339c6aa5ec. Report an issue: GitHub.

Appendix: source

Thrown at cacheengine/cachebench/trace.go:342

		if record.Schema == TraceSchema || record.Schema == TraceSchemaV2 {
			if record.ExpectedRPM <= 0 || record.ExpectedCalls <= 0 || !validTimingBasis(record.TimingBasis) {
				return nil, fmt.Errorf("cachebench: trace line %d: incomplete replay metadata", line)
			}
		}
		if record.Schema == TraceSchema {
			if record.DeclaredInputTokens <= 0 || record.DeclaredInputTokens < record.PrefixTokens || record.MaxOutputTokens <= 0 || !requestBudgetMatchesBody(record) {
				return nil, fmt.Errorf("cachebench: trace line %d: incomplete or mismatched billed-token budget", line)
			}
		}
		seen[record.RequestID] = true
		record.Body = append(json.RawMessage(nil), record.Body...)
		records = append(records, record)
	}
	if err := scanner.Err(); err != nil {
		return nil, fmt.Errorf("cachebench: read trace: %w", err)
	}
	if len(records) == 0 {
		return nil, errors.New("cachebench: no trace records")
	}
	return records, nil
}

// NativeRequest reconstructs exact optimizer input captured by v2 or v3 trace.
// Legacy v1 traces remain readable for observation joins, but cannot drive live
// replay because they omitted routing and economics inputs.
func (record TraceRecord) NativeRequest() (cacheengine.NativeRequest, error) {
	if record.Schema != TraceSchema && record.Schema != TraceSchemaV2 {
		return cacheengine.NativeRequest{}, fmt.Errorf("cachebench: request %q needs %s or %s for reconstruction", record.RequestID, TraceSchemaV2, TraceSchema)
	}
	if !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) {
		return cacheengine.NativeRequest{}, fmt.Errorf("cachebench: request %q has incomplete or invalid replay identity", record.RequestID)
	}
	return cacheengine.NativeRequest{
		Scope: record.Scope, Epoch: record.Epoch, PartitionKey: record.PartitionKey,
		ExpectedRequestsPerMinute: record.ExpectedRPM, ExpectedCalls: record.ExpectedCalls,
		Provider: record.Provider, Model: record.Model, Region: record.Region, Endpoint: record.Endpoint,

View on GitHub (pinned to 766dce6b13)