{"record":{"id":"86a9e8d4f0ad40a6","repo":"cayleygraph/cayley","slug":"erremptypath","errorCode":"ErrEmptyPath","errorMessage":"kv: path to the database must be specified","messagePattern":"kv: path to the database must be specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graph/kv/quadstore.go","lineNumber":40,"sourceCode":"\t\"fmt\"\n\t\"os\"\n\t\"sync\"\n\n\t\"github.com/cayleygraph/quad\"\n\t\"github.com/cayleygraph/quad/pquads\"\n\t\"github.com/hidal-go/hidalgo/kv\"\n\tboom \"github.com/tylertreat/BoomFilters\"\n\n\t\"github.com/cayleygraph/cayley/graph\"\n\t\"github.com/cayleygraph/cayley/graph/proto\"\n\t\"github.com/cayleygraph/cayley/graph/refs\"\n\t\"github.com/cayleygraph/cayley/internal/lru\"\n\t\"github.com/cayleygraph/cayley/query/shape\"\n)\n\nvar (\n\tErrNoBucket  = errors.New(\"kv: no bucket\")\n\tErrEmptyPath = errors.New(\"kv: path to the database must be specified\")\n)\n\ntype Registration struct {\n\tNewFunc      NewFunc\n\tInitFunc     InitFunc\n\tIsPersistent bool\n}\n\ntype InitFunc func(string, graph.Options) (kv.KV, error)\ntype NewFunc func(string, graph.Options) (kv.KV, error)\n\nfunc Register(name string, r Registration) {\n\tgraph.RegisterQuadStore(name, graph.QuadStoreRegistration{\n\t\tInitFunc: func(addr string, opt graph.Options) error {\n\t\t\tif !r.IsPersistent {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tkv, err := r.InitFunc(addr, opt)","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/graph/kv/quadstore.go#L22-L58","documentation":"ErrEmptyPath is returned by kv backend Create functions when the caller supplies an empty path string. Since kv backends store data on disk (badger, bbolt, leveldb), an empty path would be ambiguous or dangerous, so creation is rejected up front with this sentinel error.","triggerScenarios":"Calling graph/kv/{badger,bbolt,...}.Create(\"\", opts) or graph.NewInit/open paths that derive the database path from configuration where the path field is missing or empty.","commonSituations":"Missing 'storage_path' / database path entry in the Cayley config file, constructing options programmatically and forgetting the path, environment variable not set so the path defaults to \"\".","solutions":["Set the database path in your configuration (e.g. storage_path in the Cayley config) or pass a non-empty path argument.","Load the value from an environment variable or config file and validate it is non-empty before calling Create.","In code, check path != \"\" before invoking the backend registration."],"exampleFix":"// before\nkv, err := badgerdb.Create(cfg.DBPath, opts) // DBPath is \"\"\n// after\nif cfg.DBPath == \"\" {\n    return errors.New(\"config: storage path must be set\")\n}\nkv, err := badgerdb.Create(cfg.DBPath, opts)","handlingStrategy":"validation","validationCode":"if path == \"\" {\n    return errors.New(\"database path must be configured (storage_path)\")\n}","typeGuard":null,"tryCatchPattern":"kv, err := backend.Create(path, opts)\nif errors.Is(err, kv.ErrEmptyPath) {\n    return fmt.Errorf(\"configuration error: set storage_path before opening the database\")\n}","preventionTips":["Make storage_path a required config key with startup validation.","Fail fast at config-load time when the path is empty.","Provide sane defaults via environment variables for deployments."],"tags":["go","kv-store","configuration","path"],"backgroundTag":"empty-required-field","analyzedSha":"81dcd7d73e45136bc0d01802a8ba4685d8a533eb","analyzedAt":"2026-09-06T06:14:12.358Z","contentChangedAt":"2026-09-06T06:14:12.358Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}