ipfs/kubo · error

expected map for mountpoint

Error message

expected map for mountpoint

What it means

Inside MountDatastoreConfig, each element of the "mounts" array must itself be a map[string]any describing one mount. The error is thrown when an array element is not a map (e.g. a string, number, or nil), so no child spec or mountpoint can be read from it.

Source

Thrown at repo/fsrepo/datastores.go:109

	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 {
		return nil, fmt.Errorf("'mounts' field is missing or not an array")
	}
	for _, iface := range mounts {
		cfg, ok := iface.(map[string]any)
		if !ok {
			return nil, fmt.Errorf("expected map for mountpoint")
		}

		child, err := AnyDatastoreConfig(cfg)
		if err != nil {
			return nil, err
		}

		prefix, found := cfg["mountpoint"]
		if !found {
			return nil, fmt.Errorf("no 'mountpoint' on mount")
		}

		res.mounts = append(res.mounts, premount{
			ds:     child,
			prefix: ds.NewKey(prefix.(string)),
		})
	}
	sort.Slice(res.mounts,

View on GitHub (pinned to 329838acdf)

Solutions

  1. Make every element of "mounts" a JSON object (map) with at least "mountpoint" and "child" keys
  2. Re-validate the config JSON with a schema or json.Unmarshal into map[string]any and inspect the mounts array
  3. Remove null or placeholder entries from the mounts array

Example fix

// before
"mounts": ["flatfs"]
// after
"mounts": [{"mountpoint": "/blocks", "child": {"type": "flatfs", "path": "blocks"}}]
Defensive patterns

Strategy: validation

Validate before calling

for i, e := range params["mounts"].([]any) {
	if _, ok := e.(map[string]any); !ok {
		// fix mounts[i]: every entry must be an object
	}
}

Type guard

func isMountEntry(v any) (map[string]any, bool) {
	m, ok := v.(map[string]any)
	return m, ok
}

Try / catch

ds, err := fsrepo.MountDatastoreConfig(spec)
if err != nil {
	if strings.Contains(err.Error(), "expected map for mountpoint") {
		return fmt.Errorf("each mounts[] entry must be an object: %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: AnyDatastoreConfig/MountDatastoreConfig spec where the "mounts" array contains non-object entries, e.g. ["flatfs"] instead of [{"type": "flatfs", ...}], or an element that is null.

Common situations: Hand-written JSON where a mount was abbreviated to a string; arrays built in code with wrong element types; truncated or corrupted config JSON producing malformed entries.

Related errors


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