JuliusBrussee/caveman · error

ccr: recovery handle not found

Error message

ccr: recovery handle not found

What it means

The CCR (crash-consistent recovery) store's sentinel ErrNotFound. The store never guesses: a handle that is not in the local store is an explicit miss rather than a silent fallback. Returned by get, getMetadata, getObject, setObjectCurrentness, setObjectLifecycle, and findTaskDecision when the SQL query finds no row.

Solutions

  1. Confirm the handle was created by this store instance (same DB path in config).
  2. Use errors.Is(err, ccr.ErrNotFound) and fall back to re-creating the recovery record.
  3. Check the store's database file path/config — a changed path yields an empty store.
  4. Restore the missing recovery database from backup if handles are long-lived.

Example fix

// before
rec, err := store.Get(handle)
if err != nil { return err }

// after
rec, err := store.Get(handle)
if errors.Is(err, ccr.ErrNotFound) {
    return recomputeRecovery(input) // regenerate, don't guess
}
if err != nil { return err }
Defensive patterns

Strategy: fallback

Validate before calling

if handle == "" { return errors.New("handle required before Get") }

Try / catch

rec, err := store.Get(handle)
switch {
case errors.Is(err, ccr.ErrNotFound):
    return regenerateRecovery(input) // explicit miss: re-create
case err != nil:
    return fmt.Errorf("ccr get: %w", err)
}
return nil

Prevention

When it happens

Trigger: Calling Get/GetMetadata/GetObject/SetObjectCurrentness/SetObjectLifecycle/FindTaskDecision with a handle never stored in this store's database, or one that was deleted/expired; pointing the store at a different or recreated database file.

Common situations: Handle from another machine/profile; DB file deleted or moved between runs; handle typo'd or trimmed; store path changed via config so a fresh empty DB is opened.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/268fdfac933eaf98. Report an issue: GitHub.

Appendix: source

Thrown at engine/ccr/store.go:29

// platforms (store_sqlite.go) and a pure-Go in-memory map under js/wasm
// (store_wasm.go), since modernc.org/sqlite does not build for js/wasm. Both
// expose the same type and methods, so the engine is unaware of the difference.
package ccr

import (
	"bytes"
	"crypto/sha256"
	"encoding/hex"
	"errors"
	"fmt"
	"slices"
	"strings"
	"time"
)

// ErrNotFound is returned by Get when a handle is unknown. The store never
// guesses a recovery — an unknown handle is an explicit miss.
var ErrNotFound = errors.New("ccr: recovery handle not found")

// ErrBudgetExceeded means a new recovery was refused before publishing lossy
// bytes because the local store's configured payload budget would be exceeded.
// Existing handles remain intact and retrievable; callers must pass through.
var ErrBudgetExceeded = errors.New("ccr: storage budget exceeded")

// ErrStorageChanged means the recovery database no longer matches the open
// connection. Callers must preserve the original input and report the error.
var ErrStorageChanged = errors.New("ccr: recovery storage changed; restart the process and restore missing recovery files")

// ObjectType is a closed typed-working-memory enum. Unknown values fail closed:
// adapters may preserve unknown native payloads outside CCR, but may not invent
// retrieval semantics for them.
type ObjectType string

const (
	ObjectFileObservation      ObjectType = "FileObservation"
	ObjectSearchResult         ObjectType = "SearchResult"

View on GitHub (pinned to 3ee70a1026)