JuliusBrussee/caveman · error

message

Error message

message %d: %w

What it means

Wrap in validateCorpusWire: per-message validation (validateCorpusMessage) failed for the message at the interpolated index. The wrapped error names the specific defect; that message in the corpus row is at fault.

Solutions

  1. Inspect the cited message for unsupported role, oversized content, or malformed tool calls
  2. Fix or drop the message in the corpus source
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cacheengine/cachebench/corpus.go:337 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/968adf54f20df84f. Report an issue: GitHub.

Appendix: source

Thrown at cacheengine/cachebench/corpus.go:337

	if wire.OutputLength < 0 || math.IsNaN(wire.PreGap) || math.IsInf(wire.PreGap, 0) || wire.PreGap < 0 || wire.PreGap > maxCorpusGapSeconds {
		return CorpusRow{}, fmt.Errorf("output_length must be non-negative and pre_gap must be within 0..%d seconds", maxCorpusGapSeconds)
	}
	if len(wire.Input) == 0 || !json.Valid(wire.Input) {
		return CorpusRow{}, errors.New("input must be valid non-empty message array")
	}
	if len(wire.SessionID)+len(wire.Model)+len(wire.Input) > limits.MaxRowBytes {
		return CorpusRow{}, fmt.Errorf("row exceeds byte limit %d", limits.MaxRowBytes)
	}
	var messages []CorpusMessage
	if err := json.Unmarshal(wire.Input, &messages); err != nil {
		return CorpusRow{}, fmt.Errorf("decode input: %w", err)
	}
	if len(messages) == 0 || len(messages) > limits.MaxMessagesPerRequest {
		return CorpusRow{}, fmt.Errorf("message count %d outside 1..%d", len(messages), limits.MaxMessagesPerRequest)
	}
	for messageIndex, message := range messages {
		if err := validateCorpusMessage(message, limits); err != nil {
			return CorpusRow{}, fmt.Errorf("message %d: %w", messageIndex, err)
		}
	}
	return CorpusRow{
		RowIndex: index, SessionID: wire.SessionID, Model: wire.Model, Input: messages,
		OutputLength: wire.OutputLength, PreGap: wire.PreGap,
	}, nil
}

func validateCorpusMessage(message CorpusMessage, limits CorpusLimits) error {
	switch message.Role {
	case "system", "developer", "user", "assistant", "tool":
	default:
		return fmt.Errorf("unsupported role %q", message.Role)
	}
	if !validBoundedText(message.ToolCallID, 2048, true) || !validBoundedText(message.Name, 512, true) {
		return errors.New("invalid message identity")
	}
	if len(message.Content) == 0 && len(message.ToolCalls) == 0 {

View on GitHub (pinned to 766dce6b13)