JuliusBrussee/caveman · error

invalid message identity

Error message

invalid message identity

What it means

Sentinel from validateCorpusMessage: validBoundedText failed on the message's ToolCallID (max 2048, optional) or Name (max 512, optional). Optional fields must be either empty or within bounds; over-long identifiers or whitespace-only values trip this guard.

Solutions

  1. Truncate or remove oversized tool_call_id values (bound 2048 chars) and name values (bound 512 chars)
  2. Treat whitespace-only optional fields as absent by emitting them as empty strings
  3. Check for encoding artifacts (escaped JSON strings) that inflate identifier length
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

Thrown at cacheengine/cachebench/corpus.go:353

	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 {
		return errors.New("content or tool_calls required")
	}
	if len(message.Content) > limits.MaxMessageBytes || (len(message.Content) > 0 && !json.Valid(message.Content)) {
		return errors.New("content invalid or exceeds limit")
	}
	messageBytes := len(message.Content) + len(message.Role) + len(message.ToolCallID) + len(message.Name)
	if len(message.Content) > 0 {
		var content any
		if err := json.Unmarshal(message.Content, &content); err != nil {
			return errors.New("content must decode")
		}
		if content != nil {
			if _, ok := content.(string); !ok {
				return errors.New("content must be string or null")
			}
		}

View on GitHub (pinned to 766dce6b13)