JuliusBrussee/caveman · error

cacheengine: invalid cache thresholds

Error message

cacheengine: invalid cache thresholds

What it means

For a cache mode other than unsupported, validatePlanRequest found non-positive MaxBreakpoints, negative MinPrefixTokens or MaxRPMPerKey, or another threshold outside allowed bounds. These thresholds shape breakpoint placement and per-key rate limits.

Solutions

  1. Set MaxBreakpoints ≥1 and keep MinPrefixTokens/MaxRPMPerKey non-negative
  2. Use zero for MaxRPMPerKey to accept the default (15 RPM per key)
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cacheengine/engine.go:290 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/176a27be5619ec5d. Report an issue: GitHub.

Appendix: source

Thrown at cacheengine/engine.go:290

	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
}

func normalizedProfile(profile Profile) Profile {
	if profile.Mode == ModeUnsupported {
		if profile.ID == "" {
			profile.ID = "unsupported"
		}

View on GitHub (pinned to 766dce6b13)