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
- Make every element of "mounts" a JSON object (map) with at least "mountpoint" and "child" keys
- Re-validate the config JSON with a schema or json.Unmarshal into map[string]any and inspect the mounts array
- 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
- Write each mount entry as a JSON object with mountpoint and child keys
- Never abbreviate mount entries to plain strings
- Validate config JSON structure before handing specs to fsrepo
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
- 'mounts' field is missing or not an array
- no 'mountpoint' on mount
- 'name' field was missing or not a string
- 'prefix' field was missing or not a string
- mountFuse: GetConfig() failed: %s
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/a4828d0bbb064361.
Report an issue: GitHub.