cayleygraph/cayley · error

ErrQuadStoreNotRegistred

ErrQuadStoreNotRegistred

Error message

this QuadStore is not registered

What it means

NewQuadStore/InitQuadStore/UpgradeQuadStore look up the backend by name in the internal storeRegistry. If no backend with that name was registered (via init() in an imported package), the sentinel ErrQuadStoreNotRegistred is returned.

Source

Thrown at graph/registry.go:23

// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package graph

import (
	"fmt"
	"sort"
)

var (
	ErrQuadStoreNotRegistred  = fmt.Errorf("this QuadStore is not registered")
	ErrQuadStoreNotPersistent = fmt.Errorf("cannot specify address for non-persistent backend")
	ErrOperationNotSupported  = fmt.Errorf("this Operation is not supported")
)

var storeRegistry = make(map[string]QuadStoreRegistration)

type NewStoreFunc func(string, Options) (QuadStore, error)
type InitStoreFunc func(string, Options) error
type UpgradeStoreFunc func(string, Options) error

type QuadStoreRegistration struct {
	NewFunc      NewStoreFunc
	UpgradeFunc  UpgradeStoreFunc
	InitFunc     InitStoreFunc
	IsPersistent bool
}

func RegisterQuadStore(name string, register QuadStoreRegistration) {

View on GitHub (pinned to 81dcd7d73e)

Solutions

  1. Blank-import the backend package: _ "github.com/cayleygraph/cayley/graph/kv/leveldb"
  2. Check the exact registered name (see registry.Register calls or graph.ListQuadStores()) for typos
  3. Verify the backend package is still maintained in your Cayley version (some moved to nimble-coder repos)
  4. Keep blank imports in one file so lint/autocleanup doesn't remove them

Example fix

// before
import "github.com/cayleygraph/cayley/graph"
qs, err := graph.NewQuadStore("leveldb", path, nil)
// after
import (
    "github.com/cayleygraph/cayley/graph"
    _ "github.com/cayleygraph/cayley/graph/kv/leveldb"
)
qs, err := graph.NewQuadStore("leveldb", path, nil)
Defensive patterns

Strategy: try-catch

Validate before calling

import (
    "github.com/cayleygraph/cayley/graph"
    _ "github.com/cayleygraph/cayley/graph/kv/leveldb" // register backend
)
for _, name := range graph.RegisteredQuadStores() {
    if name == backendName { found = true }
}

Type guard

func backendRegistered(name string) bool {
    for _, n := range graph.RegisteredQuadStores() { if n == name { return true } }
    return false
}

Try / catch

qs, err := graph.NewQuadStore(name, path, opts)
if errors.Is(err, graph.ErrQuadStoreNotRegistred) {
    return nil, fmt.Errorf("backend %q not registered: add a blank import of its package", name)
}

Prevention

When it happens

Trigger: graph.NewQuadStore("mongodb", ...) (or Init/Upgrade) with a backend whose package was never imported, or a typo in the backend name ("leveldb" vs "level").

Common situations: Forgetting to import _ "github.com/cayleygraph/cayley/graph/nosql/..." or the specific kv backend package; renaming backends between Cayley versions; blank-import list pruned by a linter/IDE.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of cayleygraph/cayley@81dcd7d73e (2026-09-06). Data as JSON: /api/errors/365344a9ebb240fb. Report an issue: GitHub.