JuliusBrussee/caveman · error

cacheengine: unknown attribution

Error message

cacheengine: unknown attribution %q

What it means

Raised by validatePlanRequest (used by Plan and StartEpoch): the profile's attribution string is not one of the recognized attribution values. It is a whitelist check on the normalized profile that ensures accounting semantics are known before planning.

Solutions

  1. Set the profile attribution to one of the supported attribution values
  2. Check for typos when attribution comes from external config
  3. Use the engine's default attribution if the caller does not need a custom one
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cacheengine/engine.go:295 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/1c2bfa6ddc052dad. Report an issue: GitHub.

Appendix: source

Thrown at cacheengine/engine.go:295

	}
	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"
		}
		return profile
	}
	if profile.MaxBreakpoints == 0 {
		profile.MaxBreakpoints = 1
	}

View on GitHub (pinned to 766dce6b13)