JuliusBrussee/caveman · error

cacheengine: invalid profile identity

Error message

cacheengine: invalid profile identity

What it means

Thrown by validatePlanRequest when the normalized profile fails identity checks: profile.ID must be a valid non-empty identity of at most 256 bytes, Provider at most 64 bytes (optional), and OptimizerID at most 256 bytes (optional). Note normalizedProfile only auto-fills the ID for ModeUnsupported profiles; other modes must supply a valid ID.

Source

Thrown at cacheengine/engine.go:283

	}, nil
}

func validatePlanRequest(request PlanRequest) error {
	if !validIdentity(request.Scope, 4096, false) {
		return errors.New("cacheengine: invalid scope")
	}
	if !validIdentity(request.Epoch, 4096, false) {
		return errors.New("cacheengine: invalid epoch")
	}
	if !validIdentity(request.PartitionKey, 4096, true) {
		return errors.New("cacheengine: invalid partition key")
	}
	if request.ExpectedCalls < 0 || request.ExpectedRequestsPerMinute < 0 {
		return errors.New("cacheengine: negative traffic expectation")
	}
	profile := normalizedProfile(request.Profile)
	if !validIdentity(profile.ID, 256, false) || !validIdentity(profile.Provider, 64, true) || !validIdentity(profile.OptimizerID, 256, true) {
		return errors.New("cacheengine: invalid profile identity")
	}
	if profile.Mode != ModeUnsupported && profile.Mode != ModeImplicit && profile.Mode != ModeAffinity && profile.Mode != ModeExplicit {
		return fmt.Errorf("cacheengine: unknown mode %q", profile.Mode)
	}
	if profile.Mode != ModeUnsupported {
		if profile.MaxBreakpoints <= 0 || profile.MinPrefixTokens < 0 || profile.MaxRPMPerKey < 0 || profile.TTL < 0 {
			return errors.New("cacheengine: invalid cache thresholds")
		}
		switch profile.Attribution {
		case AttributionNone, AttributionOrganic, AttributionAffinity, AttributionCausal:
		default:
			return fmt.Errorf("cacheengine: unknown attribution %q", profile.Attribution)
		}
		if profile.EconomicsKnown && (!finiteNonNegative(profile.WriteMultiplier) || !finiteNonNegative(profile.ReadMultiplier)) {
			return errors.New("cacheengine: invalid cache economics")
		}
	}
	return nil

View on GitHub (pinned to 27d5a3981a)

Solutions

  1. Set a short, charset-safe Profile.ID (e.g. 'anthropic-claude-default') for any mode other than ModeUnsupported
  2. Shorten Provider to a simple provider name (<= 64 bytes) and move version info into ID or OptimizerID within limits
  3. Run your ID strings through the same character rules the library uses (plain alphanumeric/dash/underscore) before the call

Example fix

// before
profile := cacheengine.Profile{Mode: cacheengine.ModeExplicit, Provider: "anthropic/claude-3.5-sonnet@2024-10-22+us-east-1-regional-endpoint-fallback"}

// after
profile := cacheengine.Profile{ID: "claude-sonnet-default", Mode: cacheengine.ModeExplicit, Provider: "anthropic"}
Defensive patterns

Strategy: validation

Validate before calling

func profileIdentityOK(p cacheengine.Profile) bool {
    return len(p.ID) > 0 && len(p.ID) <= 256 && len(p.Provider) <= 64 && len(p.OptimizerID) <= 256
}

Type guard

// n/a (struct field validation)

Prevention

When it happens

Trigger: Calling Plan with a non-unsupported profile whose ID is empty, longer than 256 bytes, or has invalid characters; or a Provider string over 64 bytes; or an OptimizerID over 256 bytes / with invalid characters.

Common situations: Using a generated ID (UUID with braces, base64 padding) that violates the identity charset; embedding a model+version+region string as Provider that exceeds 64 bytes; forgetting to set Profile.ID when constructing a Profile literal for an explicit/affinity/implicit mode.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15). Data as JSON: /api/errors/06bc909db6515a4d. Report an issue: GitHub.