{"record":{"id":"cec299db96452a23","repo":"cayleygraph/cayley","slug":"errnotinitialized","errorCode":"ErrNotInitialized","errorMessage":"quadstore: not initialized","messagePattern":"quadstore: not initialized","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graph/quadstore.go","lineNumber":157,"sourceCode":"\n\treturn def, nil\n}\n\nfunc (d Options) BoolKey(key string, def bool) (bool, error) {\n\tif val, ok := d[key]; ok {\n\t\tif v, ok := val.(bool); ok {\n\t\t\treturn v, nil\n\t\t}\n\n\t\treturn def, fmt.Errorf(\"Invalid %s parameter type from config: %T\", key, val)\n\t}\n\n\treturn def, nil\n}\n\nvar (\n\tErrDatabaseExists = errors.New(\"quadstore: cannot init; database already exists\")\n\tErrNotInitialized = errors.New(\"quadstore: not initialized\")\n)\n","sourceCodeStart":139,"sourceCodeEnd":159,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/graph/quadstore.go#L139-L159","documentation":"ErrNotInitialized is the quadstore-level sentinel meaning the database location exists but was never initialized (no metadata). The kv backend translates the internal ErrNoBucket condition into this public error from New, so callers can detect an uninitialized store with errors.Is/graph comparison.","triggerScenarios":"Calling graph.New / kv.New on a kv path where Init never ran, so getMetadata finds no bucket and the store maps ErrNoBucket to graph.ErrNotInitialized.","commonSituations":"Pointing cayley at an empty or wrong directory; running queries/server before running init; a fresh volume in a container without the init step in the deployment pipeline.","solutions":["Run initialization first: cayley init (or graph.Init in code) to create the metadata, then open with New.","Verify the configured database path actually points at the initialized data directory.","In code, detect graph.ErrNotInitialized and branch to an init workflow rather than failing."],"exampleFix":"// before\nqs, err := graph.New(ctx, opts) // ErrNotInitialized on fresh path\n// after\nqs, err := graph.New(ctx, opts)\nif errors.Is(err, graph.ErrNotInitialized) {\n    if err := graph.Init(ctx, opts); err != nil { return err }\n    qs, err = graph.New(ctx, opts)\n}","handlingStrategy":"try-catch","validationCode":"if fi, err := os.Stat(path); err != nil || !fi.IsDir() {\n    return fmt.Errorf(\"database path %q does not exist or is not a directory\", path)\n}","typeGuard":null,"tryCatchPattern":"qs, err := graph.New(ctx, opts)\nif errors.Is(err, graph.ErrNotInitialized) {\n    if err := graph.Init(ctx, opts); err != nil { return err }\n    qs, err = graph.New(ctx, opts)\n}","preventionTips":["Run the init step in deployment pipelines before starting services.","Verify the configured database path points at the initialized volume.","Match against errors.Is(err, graph.ErrNotInitialized) instead of string comparison."],"tags":["go","quadstore","initialization","database"],"backgroundTag":"database-not-initialized","analyzedSha":"81dcd7d73e45136bc0d01802a8ba4685d8a533eb","analyzedAt":"2026-09-06T06:14:12.358Z","contentChangedAt":"2026-09-06T06:14:12.358Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}