JuliusBrussee/caveman · error
ccr sqlite path is required
Error message
ccr sqlite path is required
What it means
PrepareSQLitePathCanonical rejects an empty (or whitespace-only) SQLite path because the store cannot create or locate a database without a file path (':memory:' is the only special-case allowed). The error is returned before any filesystem work happens.
Solutions
- Provide a concrete file path when opening the store, e.g. ccr.Open("/var/lib/app/ccr.db")
- Use ":memory:" explicitly if an in-memory database is intended
- Set the missing config field or environment variable before calling Open
- Validate the path non-empty at config load time and fail early with a clear message
Example fix
// before
store, err := ccr.Open(cfg.DBPath) // cfg.DBPath == ""
// after
if strings.TrimSpace(cfg.DBPath) == "" {
return nil, fmt.Errorf("config ccr.db_path must be set")
}
store, err := ccr.Open(cfg.DBPath) Defensive patterns
Strategy: validation
Validate before calling
if strings.TrimSpace(cfg.DBPath) == "" {
return fmt.Errorf("ccr db_path is required")
} Prevention
- Validate required config fields at startup before touching the store
- Give the db path a code-level default (e.g. under os.UserCacheDir)
- Use ':memory:' explicitly for tests, never an empty string
When it happens
Trigger: Calling ccr.Open(""), ccr.Open(" "), or PrepareSQLitePath with an empty string, typically from an unset config field or environment variable.
Common situations: Missing config value for the database path; env var not set in a container; a struct field defaulted to zero value and passed straight through.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- azure legacy inference path
- bedrock request path
- cave_breaker_retry_backoff_invalid
- cave_breaker_retry_requires_budget
- cave_breaker_retry_spend_invalid
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/4c46b175362f5050.
Report an issue: GitHub.
Appendix: source
Thrown at engine/ccr/store_sqlite.go:285
// PrepareSQLitePath creates or tightens a persistent SQLite file before the
// driver sees it. Recovery databases can contain prompts, credentials, and tool
// results, so neither a permissive umask nor a caller-supplied symlink may widen
// access. Existing WAL/SHM files receive the same checks.
func PrepareSQLitePath(path string) error {
_, err := PrepareSQLitePathCanonical(path)
return err
}
// PrepareSQLitePathCanonical secures path and returns the one canonical path
// callers must use for every subsequent open and sidecar check. Returning the
// resolved parent closes the check/use gap from a swappable parent symlink.
func PrepareSQLitePathCanonical(path string) (string, error) {
if path == ":memory:" {
return path, nil
}
if strings.TrimSpace(path) == "" {
return "", fmt.Errorf("ccr sqlite path is required")
}
parent := filepath.Dir(path)
absoluteParent, err := filepath.Abs(parent)
if err != nil {
return "", fmt.Errorf("resolve sqlite parent %q: %w", parent, err)
}
resolvedParent, err := filepath.EvalSymlinks(absoluteParent)
if err != nil {
return "", fmt.Errorf("resolve sqlite parent %q: %w", parent, err)
}
parentInfo, err := os.Stat(resolvedParent)
if err != nil {
return "", fmt.Errorf("inspect sqlite parent %q: %w", resolvedParent, err)
}
if !parentInfo.IsDir() {
return "", fmt.Errorf("sqlite parent %q must be a directory", resolvedParent)
}
if err := validateSQLiteParentSecurity(resolvedParent, parentInfo); err != nil {View on GitHub (pinned to 3ee70a1026)