{"record":{"id":"693b8077a33564df","repo":"JuliusBrussee/caveman","slug":"cacheengine-stable-segment-needs-name-and-content","errorCode":null,"errorMessage":"cacheengine: stable segment needs name and content","messagePattern":"cacheengine: stable segment needs name and content","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/engine.go","lineNumber":332,"sourceCode":"\tif profile.MaxRPMPerKey == 0 {\n\t\tprofile.MaxRPMPerKey = 15\n\t}\n\tif profile.Attribution == \"\" {\n\t\tprofile.Attribution = AttributionNone\n\t}\n\treturn profile\n}\n\nfunc stablePrefix(segments []Segment, maxBytes int) ([]byte, []Segment, error) {\n\tvar prefix []byte\n\tvar stable []Segment\n\tseenNames := map[string]bool{}\n\tfor _, segment := range segments {\n\t\tif !segment.Stable || !segment.Cacheable {\n\t\t\tbreak\n\t\t}\n\t\tif !validIdentity(segment.Name, 1024, false) || len(segment.Content) == 0 || seenNames[segment.Name] {\n\t\t\treturn nil, nil, errors.New(\"cacheengine: stable segment needs name and content\")\n\t\t}\n\t\tseenNames[segment.Name] = true\n\t\tif segment.Tokens < 0 || segment.ExpectedCalls < 0 {\n\t\t\treturn nil, nil, errors.New(\"cacheengine: negative segment measurement\")\n\t\t}\n\t\tif maxBytes < 8 || len(segment.Name) > maxBytes-8 || len(segment.Content) > maxBytes-8-len(segment.Name) || len(prefix) > maxBytes-8-len(segment.Name)-len(segment.Content) {\n\t\t\treturn nil, nil, errors.New(\"cacheengine: stable prefix exceeds configured byte limit\")\n\t\t}\n\t\tif len(segment.Name) > math.MaxUint32 || len(segment.Content) > math.MaxUint32 {\n\t\t\treturn nil, nil, errors.New(\"cacheengine: segment exceeds framing limit\")\n\t\t}\n\t\tprefix = appendFrame(prefix, segment.Name, segment.Content)\n\t\tstable = append(stable, segment)\n\t}\n\treturn prefix, stable, nil\n}\n\nfunc appendFrame(dst []byte, name string, content []byte) []byte {","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/engine.go#L314-L350","documentation":"stablePrefix found a Stable+Cacheable segment whose Name is empty/invalid (over 1024 bytes or bad characters), whose Content is empty, or whose Name duplicates an earlier segment in the same prefix. Names frame segments for prefix hashing, so they must be unique and non-empty.","triggerScenarios":"Thrown at cacheengine/engine.go:332 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Give every stable segment a unique, non-empty name ≤1024 bytes","Ensure each stable segment carries non-empty content or is marked non-stable"],"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"}