ipfs/kubo · error

unknown datastore type: %s

Error message

unknown datastore type: %s

What it means

AnyDatastoreConfig could not map the 'type' field of a Datastore.Spec entry to a registered datastore builder: the configured type string is not one of the built-in types (mount, measure, levelds, flatfs, etc.) and no plugin registered one under that name.

Source

Thrown at repo/fsrepo/datastores.go:85

	_, ok := datastores[name]
	if ok {
		return fmt.Errorf("already have a datastore named %q", name)
	}

	datastores[name] = dsc
	return nil
}

// AnyDatastoreConfig returns a DatastoreConfig from a spec based on
// the "type" parameter.
func AnyDatastoreConfig(params map[string]any) (DatastoreConfig, error) {
	which, ok := params["type"].(string)
	if !ok {
		return nil, fmt.Errorf("'type' field missing or not a string")
	}
	fun, ok := datastores[which]
	if !ok {
		return nil, fmt.Errorf("unknown datastore type: %s", which)
	}
	return fun(params)
}

type mountDatastoreConfig struct {
	mounts []premount
}

type premount struct {
	ds     DatastoreConfig
	prefix ds.Key
}

// MountDatastoreConfig returns a mount DatastoreConfig from a spec.
func MountDatastoreConfig(params map[string]any) (DatastoreConfig, error) {
	var res mountDatastoreConfig
	mounts, ok := params["mounts"].([]any)
	if !ok {

View on GitHub (pinned to 329838acdf)

Solutions

  1. Use a supported type: levelds, flatfs, mount, measure, badgerds (if enabled), memds, or a plugin-provided type
  2. Check for typos in Datastore.Spec.type
  3. See docs/datastores.md for the supported types and examples

Example fix

// before
spec := map[string]any{"type": "flatNs", "path": "/datastore"}
// after
spec := map[string]any{"type": "flatfs", "path": "/datastore"}
Defensive patterns

Strategy: validation

Validate before calling

t, _ := params["type"].(string)
known := map[string]bool{"mounts":true,"flatfs":true,"levelds":true,"log":true,"measure":true}
if !known[t] { /* fix type name before calling */ }

Type guard

func knownDatastoreType(params map[string]any) bool {
	t, ok := params["type"].(string)
	return ok && t != ""
}

Try / catch

ds, err := fsrepo.AnyDatastoreConfig(spec)
if err != nil {
	if strings.HasPrefix(err.Error(), "unknown datastore type") {
		return fmt.Errorf("spec type %q not supported by this build: %w", spec["type"], err)
	}
	return err
}

Prevention

When it happens

Trigger: AnyDatastoreConfig called with params["type"] set to a string that is not a key of the datastores map (e.g. "goleveldb", "flatfs " with whitespace, wrong case).

Common situations: Typo in the datastore type in the config's Datastore.Spec; copying a spec from another implementation or a newer kubo version that registers types this build does not have; extra whitespace or casing in the type name.

Related errors


AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03). Data as JSON: /api/errors/9f4e890a8c06e8fa. Report an issue: GitHub.