JuliusBrussee/caveman · error
resolve sqlite parent
Error message
resolve sqlite parent %q: %w
What it means
This error wraps a failure of filepath.Abs or filepath.EvalSymlinks on the database path's parent directory while canonicalizing the SQLite path. It is thrown when the parent directory cannot be resolved to a real absolute path, most commonly because EvalSymlinks fails with ENOENT when the parent directory does not exist.
Solutions
- Create the parent directory first: os.MkdirAll(filepath.Dir(path), 0o755)
- Verify any symlinks in the path actually resolve (ls -L the parent)
- Mount the expected volume/container path before starting the app
- Correct the configured path if it points at a nonexistent location
Example fix
// before
store, err := ccr.Open("/var/lib/app/ccr.db") // /var/lib/app missing
// after
if err := os.MkdirAll("/var/lib/app", 0o755); err != nil {
return err
}
store, err := ccr.Open("/var/lib/app/ccr.db") Defensive patterns
Strategy: validation
Validate before calling
parent := filepath.Dir(dbPath)
if _, err := filepath.EvalSymlinks(parent); err != nil {
if err := os.MkdirAll(parent, 0o755); err != nil {
return fmt.Errorf("create db dir %s: %w", parent, err)
}
} Prevention
- Always os.MkdirAll the db directory before first open
- Mount required volumes before app start in containers
- Check for broken symlinks in configured paths
When it happens
Trigger: Passing a path whose parent directory has not been created yet (e.g. /var/lib/app/ccr.db when /var/lib/app does not exist), or a path with an unresolvable symlink chain.
Common situations: First-run deployments where the data directory was never created; deleted data directories; Docker volumes not mounted; broken symlinks in the path.
Related errors
- : database parent changed
- : : inspect database parent
- caveman build: package artifact symlink is not lockable
- caveman build: source graph symlink escapes project root
- ccr sqlite path is required
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/931e9f6f61139fa0.
Report an issue: GitHub.
Appendix: source
Thrown at engine/ccr/store_sqlite.go:290
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 {
return "", err
}
canonicalPath := filepath.Join(resolvedParent, filepath.Base(path))
if err := secureSQLiteFile(canonicalPath, true); err != nil {
return "", fmt.Errorf("secure sqlite %q: %w", canonicalPath, err)View on GitHub (pinned to 3ee70a1026)