{"record":{"id":"3f4309e043c910b9","repo":"JuliusBrussee/caveman","slug":"ccr-unknown-object-type-q","errorCode":null,"errorMessage":"ccr: unknown object type %q","messagePattern":"ccr: unknown object type %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/ccr/store.go","lineNumber":107,"sourceCode":"\tCurrentness        Currentness `json:\"currentness\"`\n\tLifecycle          Lifecycle   `json:\"lifecycle\"`\n\tDependencies       []string    `json:\"dependencies\"`\n\tOriginalByteLength int         `json:\"original_byte_length\"`\n\tStoredByteLength   int         `json:\"stored_byte_length\"`\n\tData               []byte      `json:\"data\"`\n}\n\nvar objectTypes = map[ObjectType]struct{}{\n\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()","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/engine/ccr/store.go#L89-L125","documentation":"prepareObject validates every Object before it is written to the CCR SQLite store. The object's Type field must exactly match one of the registered object types (the objectTypes map, e.g. ObjectDocumentationExcerpt, ObjectBrowserSnapshot, ObjectRepositoryMap, ObjectEvidenceBundle); any other value is rejected with this error and nothing is stored. It is a closed-enum type check that keeps the recovery store's records well-formed.","triggerScenarios":"Calling PutObject (or internal putObject) with an Object whose Type string is empty, mistyped, or not one of the enumerated Object* constants — e.g. a raw string like \"doc\" instead of the exported constant, or a constant removed/renamed in a version change.","commonSituations":"Constructing an Object by hand with a free-form type string instead of the library's exported Object* constants; upgrading the library where an object type constant was renamed or deleted; copying sample code that used an older/invalid type value.","solutions":["Set obj.Type to one of the library's exported object type constants (e.g. ObjectDocumentationExcerpt, ObjectBrowserSnapshot, ObjectRepositoryMap, ObjectEvidenceBundle) instead of a string literal","Check for typos or casing differences between your value and the constant names","If migrating from an older version, update code that referenced removed/renamed Object type constants to the current set","Inspect the objectTypes map in engine/ccr/store.go for the exact accepted set of types"],"exampleFix":"// before\nobj := ccr.Object{Type: \"documentation\", SessionID: sid, Payload: p}\n// after\nobj := ccr.Object{Type: ccr.ObjectDocumentationExcerpt, SessionID: sid, Payload: p}","handlingStrategy":"validation","validationCode":"// Validate the object type before calling PutObject\nfunc validObjectType(t ccr.ObjectType) bool {\n  switch t {\n  case ccr.ObjectDocumentationExcerpt, ccr.ObjectBrowserSnapshot,\n    ccr.ObjectRepositoryMap, ccr.ObjectEvidenceBundle:\n    return true\n  }\n  return false\n}\nif !validObjectType(obj.Type) { return fmt.Errorf(\"unsupported object type %q\", obj.Type) }","typeGuard":"func isStoredObject(v any) (ccr.Object, bool) {\n  obj, ok := v.(ccr.Object)\n  if !ok || !validObjectType(obj.Type) || strings.TrimSpace(obj.SessionID) == \"\" {\n    return ccr.Object{}, false\n  }\n  return obj, true\n}","tryCatchPattern":"if _, err := store.PutObject(ctx, obj); err != nil {\n  if strings.Contains(err.Error(), \"unknown object type\") {\n    return fmt.Errorf(\"object type %q is not part of the CCR enum; use an exported Object* constant: %w\", obj.Type, err)\n  }\n  return err\n}","preventionTips":["Always use the exported Object* constants, never raw strings, for Object.Type","Add a unit test that constructs each object type you use so renames/removals break at compile/test time","Check the objectTypes map in engine/ccr/store.go when upgrading versions","Reject invalid types at your application boundary before handing objects to the store"],"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"}