{"record":{"id":"2ba8567118f195e8","repo":"JuliusBrussee/caveman","slug":"ccr-put-w","errorCode":null,"errorMessage":"ccr put: %w","messagePattern":"ccr put: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/ccr/store_sqlite.go","lineNumber":358,"sourceCode":"\t}\n\t_, err = db.Exec(`ALTER TABLE recoveries ADD COLUMN metadata BLOB`)\n\treturn err\n}\n\n// OpenMemory opens an ephemeral in-memory store.\nfunc OpenMemory() (*Store, error) { return OpenWithBudget(\":memory:\", DefaultMaxStorageBytes) }\n\n// Close closes the underlying database.\nfunc (s *Store) Close() error { return s.db.Close() }\n\n// Put stores a recovery and returns its handle. It is idempotent: storing the\n// same original twice (the handle is derived from the bytes) overwrites the row\n// with identical content and returns the same handle.\nfunc (s *Store) Put(rec Recovery) (string, error) {\n\thandle := Handle(rec.Original)\n\tunchanged, err := s.recoveryUnchanged(handle, rec)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"ccr put: %w\", err)\n\t}\n\tif unchanged {\n\t\treturn handle, nil\n\t}\n\tif err := s.checkRecoveryBudget(handle, int64(len(rec.Original)+len(rec.Metadata))); err != nil {\n\t\treturn \"\", fmt.Errorf(\"ccr put: %w\", err)\n\t}\n\t_, err = s.db.Exec(\n\t\t`INSERT INTO recoveries (handle, created_at, content_type, compressor, tokens_before, tokens_after, original, metadata)\n\t\t VALUES (?,?,?,?,?,?,?,?)\n\t\t ON CONFLICT(handle) DO UPDATE SET\n\t\t   created_at=excluded.created_at,\n\t\t   content_type=CASE WHEN excluded.tokens_before = 0 AND recoveries.tokens_before > 0 THEN recoveries.content_type ELSE excluded.content_type END,\n\t\t   compressor=CASE WHEN excluded.tokens_before = 0 AND recoveries.tokens_before > 0 THEN recoveries.compressor ELSE excluded.compressor END,\n\t\t   tokens_before=CASE WHEN excluded.tokens_before = 0 AND recoveries.tokens_before > 0 THEN recoveries.tokens_before ELSE excluded.tokens_before END,\n\t\t   tokens_after=CASE WHEN excluded.tokens_before = 0 AND recoveries.tokens_before > 0 THEN recoveries.tokens_after ELSE excluded.tokens_after END,\n\t\t   original=excluded.original,\n\t\t   metadata=CASE","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/engine/ccr/store_sqlite.go#L340-L376","documentation":"Wraps the recovery-row INSERT failure in Store.Put. Covers any driver-level failure inserting the (handle-derived) recovery row, including budget-full conditions surfaced by the database — the caller decides whether to pass through without compression.","triggerScenarios":"Thrown at engine/ccr/store_sqlite.go:358 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the wrapped error; 'database or disk is full' indicates ErrBudgetExceeded semantics — evict or raise the budget","For CCR failures the engine contract is pass-through: return the original bytes rather than failing the request","Verify the database is not locked by another process and retry"],"exampleFix":null,"handlingStrategy":"try-catch","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"}