cayleygraph/cayley · error
ErrEmptyPath
ErrEmptyPath
Error message
kv: path to the database must be specified
What it means
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.
Source
Thrown at graph/kv/quadstore.go:40
"fmt"
"os"
"sync"
"github.com/cayleygraph/quad"
"github.com/cayleygraph/quad/pquads"
"github.com/hidal-go/hidalgo/kv"
boom "github.com/tylertreat/BoomFilters"
"github.com/cayleygraph/cayley/graph"
"github.com/cayleygraph/cayley/graph/proto"
"github.com/cayleygraph/cayley/graph/refs"
"github.com/cayleygraph/cayley/internal/lru"
"github.com/cayleygraph/cayley/query/shape"
)
var (
ErrNoBucket = errors.New("kv: no bucket")
ErrEmptyPath = errors.New("kv: path to the database must be specified")
)
type Registration struct {
NewFunc NewFunc
InitFunc InitFunc
IsPersistent bool
}
type InitFunc func(string, graph.Options) (kv.KV, error)
type NewFunc func(string, graph.Options) (kv.KV, error)
func Register(name string, r Registration) {
graph.RegisterQuadStore(name, graph.QuadStoreRegistration{
InitFunc: func(addr string, opt graph.Options) error {
if !r.IsPersistent {
return nil
}
kv, err := r.InitFunc(addr, opt)View on GitHub (pinned to 81dcd7d73e)
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.
Example fix
// before
kv, err := badgerdb.Create(cfg.DBPath, opts) // DBPath is ""
// after
if cfg.DBPath == "" {
return errors.New("config: storage path must be set")
}
kv, err := badgerdb.Create(cfg.DBPath, opts) Defensive patterns
Strategy: validation
Validate before calling
if path == "" {
return errors.New("database path must be configured (storage_path)")
} Try / catch
kv, err := backend.Create(path, opts)
if errors.Is(err, kv.ErrEmptyPath) {
return fmt.Errorf("configuration error: set storage_path before opening the database")
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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 "".
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
- ErrNoBucket
- kv: data version is out of date. Run cayleyupgrade for your
- unknown quad format %q
- iterator already used in query
- HTTP Request needed
AI-assisted analysis of cayleygraph/cayley@81dcd7d73e (2026-09-06).
Data as JSON: /api/errors/86a9e8d4f0ad40a6.
Report an issue: GitHub.