{"record":{"id":"4c46b175362f5050","repo":"JuliusBrussee/caveman","slug":"ccr-sqlite-path-is-required","errorCode":null,"errorMessage":"ccr sqlite path is required","messagePattern":"ccr sqlite path is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/ccr/store_sqlite.go","lineNumber":285,"sourceCode":"\n// PrepareSQLitePath creates or tightens a persistent SQLite file before the\n// driver sees it. Recovery databases can contain prompts, credentials, and tool\n// results, so neither a permissive umask nor a caller-supplied symlink may widen\n// access. Existing WAL/SHM files receive the same checks.\nfunc PrepareSQLitePath(path string) error {\n\t_, err := PrepareSQLitePathCanonical(path)\n\treturn err\n}\n\n// PrepareSQLitePathCanonical secures path and returns the one canonical path\n// callers must use for every subsequent open and sidecar check. Returning the\n// resolved parent closes the check/use gap from a swappable parent symlink.\nfunc PrepareSQLitePathCanonical(path string) (string, error) {\n\tif path == \":memory:\" {\n\t\treturn path, nil\n\t}\n\tif strings.TrimSpace(path) == \"\" {\n\t\treturn \"\", fmt.Errorf(\"ccr sqlite path is required\")\n\t}\n\tparent := filepath.Dir(path)\n\tabsoluteParent, err := filepath.Abs(parent)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"resolve sqlite parent %q: %w\", parent, err)\n\t}\n\tresolvedParent, err := filepath.EvalSymlinks(absoluteParent)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"resolve sqlite parent %q: %w\", parent, err)\n\t}\n\tparentInfo, err := os.Stat(resolvedParent)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"inspect sqlite parent %q: %w\", resolvedParent, err)\n\t}\n\tif !parentInfo.IsDir() {\n\t\treturn \"\", fmt.Errorf(\"sqlite parent %q must be a directory\", resolvedParent)\n\t}\n\tif err := validateSQLiteParentSecurity(resolvedParent, parentInfo); err != nil {","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/engine/ccr/store_sqlite.go#L267-L303","documentation":"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.","triggerScenarios":"Calling ccr.Open(\"\"), ccr.Open(\"   \"), or PrepareSQLitePath with an empty string, typically from an unset config field or environment variable.","commonSituations":"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.","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"],"exampleFix":"// before\nstore, err := ccr.Open(cfg.DBPath) // cfg.DBPath == \"\"\n// after\nif strings.TrimSpace(cfg.DBPath) == \"\" {\n    return nil, fmt.Errorf(\"config ccr.db_path must be set\")\n}\nstore, err := ccr.Open(cfg.DBPath)","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(cfg.DBPath) == \"\" {\n    return fmt.Errorf(\"ccr db_path is required\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["sqlite","path","validation","config"],"backgroundTag":"empty-required-field","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"}