{"record":{"id":"176a27be5619ec5d","repo":"JuliusBrussee/caveman","slug":"cacheengine-invalid-cache-thresholds","errorCode":null,"errorMessage":"cacheengine: invalid cache thresholds","messagePattern":"cacheengine: invalid cache thresholds","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/engine.go","lineNumber":290,"sourceCode":"\tif !validIdentity(request.Epoch, 4096, false) {\n\t\treturn errors.New(\"cacheengine: invalid epoch\")\n\t}\n\tif !validIdentity(request.PartitionKey, 4096, true) {\n\t\treturn errors.New(\"cacheengine: invalid partition key\")\n\t}\n\tif request.ExpectedCalls < 0 || request.ExpectedRequestsPerMinute < 0 {\n\t\treturn errors.New(\"cacheengine: negative traffic expectation\")\n\t}\n\tprofile := normalizedProfile(request.Profile)\n\tif !validIdentity(profile.ID, 256, false) || !validIdentity(profile.Provider, 64, true) || !validIdentity(profile.OptimizerID, 256, true) {\n\t\treturn errors.New(\"cacheengine: invalid profile identity\")\n\t}\n\tif profile.Mode != ModeUnsupported && profile.Mode != ModeImplicit && profile.Mode != ModeAffinity && profile.Mode != ModeExplicit {\n\t\treturn fmt.Errorf(\"cacheengine: unknown mode %q\", profile.Mode)\n\t}\n\tif profile.Mode != ModeUnsupported {\n\t\tif profile.MaxBreakpoints <= 0 || profile.MinPrefixTokens < 0 || profile.MaxRPMPerKey < 0 || profile.TTL < 0 {\n\t\t\treturn errors.New(\"cacheengine: invalid cache thresholds\")\n\t\t}\n\t\tswitch profile.Attribution {\n\t\tcase AttributionNone, AttributionOrganic, AttributionAffinity, AttributionCausal:\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"cacheengine: unknown attribution %q\", profile.Attribution)\n\t\t}\n\t\tif profile.EconomicsKnown && (!finiteNonNegative(profile.WriteMultiplier) || !finiteNonNegative(profile.ReadMultiplier)) {\n\t\t\treturn errors.New(\"cacheengine: invalid cache economics\")\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc normalizedProfile(profile Profile) Profile {\n\tif profile.Mode == ModeUnsupported {\n\t\tif profile.ID == \"\" {\n\t\t\tprofile.ID = \"unsupported\"\n\t\t}","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/engine.go#L272-L308","documentation":"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.","triggerScenarios":"Thrown at cacheengine/engine.go:290 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set MaxBreakpoints ≥1 and keep MinPrefixTokens/MaxRPMPerKey non-negative","Use zero for MaxRPMPerKey to accept the default (15 RPM per key)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}