{"record":{"id":"2d7798ad5b55a85a","repo":"JuliusBrussee/caveman","slug":"cacheengine-invalid-cache-economics","errorCode":null,"errorMessage":"cacheengine: invalid cache economics","messagePattern":"cacheengine: invalid cache economics","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/engine.go","lineNumber":298,"sourceCode":"\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}\n\t\treturn profile\n\t}\n\tif profile.MaxBreakpoints == 0 {\n\t\tprofile.MaxBreakpoints = 1\n\t}\n\tif profile.MaxRPMPerKey == 0 {\n\t\tprofile.MaxRPMPerKey = 15\n\t}","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/engine.go#L280-L316","documentation":"While scoring breakpoint candidates, the net-savings computation produced NaN or ±Inf — the economics inputs (cumulative tokens, calls, write/read multipliers) combine to a non-finite number, so the profit model cannot be trusted.","triggerScenarios":"Thrown at cacheengine/engine.go:298 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use finite, sane write/read multipliers in the profile economics","Shrink segment token counts and expected calls to non-overflowing magnitudes"],"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"}