{"record":{"id":"06bc909db6515a4d","repo":"JuliusBrussee/caveman","slug":"cacheengine-invalid-profile-identity","errorCode":null,"errorMessage":"cacheengine: invalid profile identity","messagePattern":"cacheengine: invalid profile identity","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/engine.go","lineNumber":283,"sourceCode":"\t}, nil\n}\n\nfunc validatePlanRequest(request PlanRequest) error {\n\tif !validIdentity(request.Scope, 4096, false) {\n\t\treturn errors.New(\"cacheengine: invalid scope\")\n\t}\n\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","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/cacheengine/engine.go#L265-L301","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set a short, charset-safe Profile.ID (e.g. 'anthropic-claude-default') for any mode other than ModeUnsupported","Shorten Provider to a simple provider name (<= 64 bytes) and move version info into ID or OptimizerID within limits","Run your ID strings through the same character rules the library uses (plain alphanumeric/dash/underscore) before the call"],"exampleFix":"// before\nprofile := cacheengine.Profile{Mode: cacheengine.ModeExplicit, Provider: \"anthropic/claude-3.5-sonnet@2024-10-22+us-east-1-regional-endpoint-fallback\"}\n\n// after\nprofile := cacheengine.Profile{ID: \"claude-sonnet-default\", Mode: cacheengine.ModeExplicit, Provider: \"anthropic\"}","handlingStrategy":"validation","validationCode":"func profileIdentityOK(p cacheengine.Profile) bool {\n    return len(p.ID) > 0 && len(p.ID) <= 256 && len(p.Provider) <= 64 && len(p.OptimizerID) <= 256\n}","typeGuard":"// n/a (struct field validation)","tryCatchPattern":null,"preventionTips":["Use short slug-style IDs (alnum, dash, underscore)","Never leave Profile.ID empty for non-unsupported modes"],"tags":["cacheengine","validation","profile","go"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}