{"record":{"id":"57b773ebf816bb1a","repo":"JuliusBrussee/caveman","slug":"ccr-unknown-currentness-q","errorCode":null,"errorMessage":"ccr: unknown currentness %q","messagePattern":"ccr: unknown currentness %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/ccr/store.go","lineNumber":116,"sourceCode":"\tObjectFileObservation: {}, ObjectSearchResult: {}, ObjectCommandResult: {},\n\tObjectTestResult: {}, ObjectBuildResult: {}, ObjectDiffSnapshot: {},\n\tObjectTaskContract: {}, ObjectTaskDecision: {}, ObjectExecutionState: {},\n\tObjectDocumentationExcerpt: {}, ObjectBrowserSnapshot: {},\n\tObjectRepositoryMap: {}, ObjectEvidenceBundle: {},\n}\n\nfunc prepareObject(obj Object) (Object, error) {\n\tif _, ok := objectTypes[obj.Type]; !ok {\n\t\treturn Object{}, fmt.Errorf(\"ccr: unknown object type %q\", obj.Type)\n\t}\n\tif strings.TrimSpace(obj.SessionID) == \"\" {\n\t\treturn Object{}, errors.New(\"ccr: typed object session_id is required\")\n\t}\n\tif obj.Currentness == \"\" {\n\t\tobj.Currentness = Current\n\t}\n\tif obj.Currentness != Current && obj.Currentness != Stale && obj.Currentness != Archived {\n\t\treturn Object{}, fmt.Errorf(\"ccr: unknown currentness %q\", obj.Currentness)\n\t}\n\tif obj.Lifecycle == \"\" {\n\t\tobj.Lifecycle = Hot\n\t}\n\tif obj.Lifecycle != Hot && obj.Lifecycle != Warm && obj.Lifecycle != Cold && obj.Lifecycle != LifecycleArchived {\n\t\treturn Object{}, fmt.Errorf(\"ccr: unknown lifecycle %q\", obj.Lifecycle)\n\t}\n\tif obj.CreatedAt.IsZero() {\n\t\tobj.CreatedAt = time.Now().UTC()\n\t} else {\n\t\tobj.CreatedAt = obj.CreatedAt.UTC()\n\t}\n\tdataSum := sha256.Sum256(obj.Data)\n\tcomputedHash := \"sha256:\" + hex.EncodeToString(dataSum[:])\n\tif obj.ContentHash == \"\" {\n\t\tobj.ContentHash = computedHash\n\t} else if obj.ContentHash != computedHash {\n\t\treturn Object{}, errors.New(\"ccr: typed object content_hash does not match data\")","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/engine/ccr/store.go#L98-L134","documentation":"prepareObject validates the Object's Currentness field before persisting to the CCR store. Empty defaults to Current, but any other value must be exactly Current, Stale, or Archived; anything else is rejected with this error. This keeps lifecycle queries over stored objects deterministic and the enum closed.","triggerScenarios":"Calling PutObject (or internal putObject) with an Object whose Currentness is a non-empty string other than Current/Stale/Archived — e.g. a custom value like \"fresh\", a differently-cased \"CURRENT\", or a value produced by another system's lifecycle enum.","commonSituations":"Mapping an application's own staleness states onto CCR objects without translating them to the library's three-value enum; case mismatches after reading the value from config or JSON; version drift where a formerly accepted value is no longer in the enum.","solutions":["Set obj.Currentness to one of ccr.Current, ccr.Stale, or ccr.Archived (or leave it empty to default to Current)","Normalize case and whitespace before assigning — the comparison is exact string equality","Translate your application's lifecycle states into the three supported values at the boundary (e.g. map \"fresh\"/\"new\" → ccr.Current)","Check the enum constants in engine/ccr/store.go for the exact accepted values"],"exampleFix":"// before\nobj := ccr.Object{Type: ccr.ObjectRepositoryMap, Currentness: \"fresh\"}\n// after\nobj := ccr.Object{Type: ccr.ObjectRepositoryMap, Currentness: ccr.Current}","handlingStrategy":"validation","validationCode":"// Normalize and validate Currentness before PutObject\nswitch strings.TrimSpace(string(obj.Currentness)) {\ncase \"\", string(ccr.Current):\n  obj.Currentness = ccr.Current\ncase string(ccr.Stale):\n  obj.Currentness = ccr.Stale\ncase string(ccr.Archived):\n  obj.Currentness = ccr.Archived\ndefault:\n  return fmt.Errorf(\"currentness %q must be Current, Stale, or Archived\", obj.Currentness)\n}","typeGuard":"func isCurrentness(v string) bool {\n  switch ccr.Currentness(v) {\n  case ccr.Current, ccr.Stale, ccr.Archived:\n    return true\n  }\n  return false\n}","tryCatchPattern":"if _, err := store.PutObject(ctx, obj); err != nil {\n  if strings.Contains(err.Error(), \"unknown currentness\") {\n    return fmt.Errorf(\"currentness %q not in {Current,Stale,Archived}; map your lifecycle states to the CCR enum: %w\", obj.Currentness, err)\n  }\n  return err\n}","preventionTips":["Leave Currentness empty when the object is current — the store defaults it to Current","Translate application-specific lifecycle enums to CCR's three values at the boundary","Centralize object construction in one constructor that validates Currentness","Re-check the enum constants after library upgrades in case the accepted set changes"],"tags":["validation","enum","store"],"backgroundTag":"invalid-enum-value","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}