{"record":{"id":"a4828d0bbb064361","repo":"ipfs/kubo","slug":"expected-map-for-mountpoint","errorCode":null,"errorMessage":"expected map for mountpoint","messagePattern":"expected map for mountpoint","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"repo/fsrepo/datastores.go","lineNumber":109,"sourceCode":"\tmounts []premount\n}\n\ntype premount struct {\n\tds     DatastoreConfig\n\tprefix ds.Key\n}\n\n// MountDatastoreConfig returns a mount DatastoreConfig from a spec.\nfunc MountDatastoreConfig(params map[string]any) (DatastoreConfig, error) {\n\tvar res mountDatastoreConfig\n\tmounts, ok := params[\"mounts\"].([]any)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"'mounts' field is missing or not an array\")\n\t}\n\tfor _, iface := range mounts {\n\t\tcfg, ok := iface.(map[string]any)\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"expected map for mountpoint\")\n\t\t}\n\n\t\tchild, err := AnyDatastoreConfig(cfg)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tprefix, found := cfg[\"mountpoint\"]\n\t\tif !found {\n\t\t\treturn nil, fmt.Errorf(\"no 'mountpoint' on mount\")\n\t\t}\n\n\t\tres.mounts = append(res.mounts, premount{\n\t\t\tds:     child,\n\t\t\tprefix: ds.NewKey(prefix.(string)),\n\t\t})\n\t}\n\tsort.Slice(res.mounts,","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/repo/fsrepo/datastores.go#L91-L127","documentation":"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.","triggerScenarios":"AnyDatastoreConfig/MountDatastoreConfig spec where the \"mounts\" array contains non-object entries, e.g. [\"flatfs\"] instead of [{\"type\": \"flatfs\", ...}], or an element that is null.","commonSituations":"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.","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"],"exampleFix":"// before\n\"mounts\": [\"flatfs\"]\n// after\n\"mounts\": [{\"mountpoint\": \"/blocks\", \"child\": {\"type\": \"flatfs\", \"path\": \"blocks\"}}]","handlingStrategy":"validation","validationCode":"for i, e := range params[\"mounts\"].([]any) {\n\tif _, ok := e.(map[string]any); !ok {\n\t\t// fix mounts[i]: every entry must be an object\n\t}\n}","typeGuard":"func isMountEntry(v any) (map[string]any, bool) {\n\tm, ok := v.(map[string]any)\n\treturn m, ok\n}","tryCatchPattern":"ds, err := fsrepo.MountDatastoreConfig(spec)\nif err != nil {\n\tif strings.Contains(err.Error(), \"expected map for mountpoint\") {\n\t\treturn fmt.Errorf(\"each mounts[] entry must be an object: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["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"],"tags":["datastore","config","mount","validation","go"],"backgroundTag":"datastore-spec-invalid","analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}