ipfs/kubo · error
'name' field was missing or not a string
Error message
'name' field was missing or not a string
What it means
LogDatastoreConfig reads params["name"] to label log events emitted by the wrapping datastore. When "name" is absent or not a string, the wrapper cannot be identified in logs, so the error is returned.
Source
Thrown at repo/fsrepo/datastores.go:197
type logDatastoreConfig struct {
child DatastoreConfig
name string
}
// LogDatastoreConfig returns a log DatastoreConfig from a spec.
func LogDatastoreConfig(params map[string]any) (DatastoreConfig, error) {
childField, ok := params["child"].(map[string]any)
if !ok {
return nil, fmt.Errorf("'child' field is missing or not a map")
}
child, err := AnyDatastoreConfig(childField)
if err != nil {
return nil, err
}
name, ok := params["name"].(string)
if !ok {
return nil, fmt.Errorf("'name' field was missing or not a string")
}
return &logDatastoreConfig{child, name}, nil
}
func (c *logDatastoreConfig) Create(path string) (repo.Datastore, error) {
child, err := c.child.Create(path)
if err != nil {
return nil, err
}
return ds.NewLogDatastore(child, c.name), nil
}
func (c *logDatastoreConfig) DiskSpec() DiskSpec {
return c.child.DiskSpec()
}
type measureDatastoreConfig struct {
child DatastoreConfigView on GitHub (pinned to 329838acdf)
Solutions
- Add "name" as a string to the log datastore spec (e.g. "name": "datastore-log")
- Coerce or fix the value so it is a Go string in the spec map
Example fix
// before
spec := map[string]any{"type": "log", "child": childSpec}
// after
spec := map[string]any{"type": "log", "name": "dslog", "child": childSpec} Defensive patterns
Strategy: validation
Validate before calling
n, ok := params["name"].(string)
if !ok || n == "" { /* add name before calling */ } Type guard
func logName(params map[string]any) (string, bool) {
n, ok := params["name"].(string)
return n, ok && n != ""
} Try / catch
ds, err := fsrepo.LogDatastoreConfig(spec)
if err != nil {
if strings.Contains(err.Error(), "'name' field") {
return fmt.Errorf("log spec requires a name: %w", err)
}
return err
} Prevention
- Always set "name" as a string in log datastore specs
- Use a descriptive, stable name since it labels emitted log events
- Type-check programmatically built maps before calling
When it happens
Trigger: Calling LogDatastoreConfig with a valid "child" but where params["name"] is missing, nil, or a non-string value (e.g. a number).
Common situations: Spec of type "log" with "child" filled in but the "name" field forgotten; name provided as a non-string in programmatically built maps.
Related errors
- 'mounts' field is missing or not an array
- expected map for mountpoint
- no 'mountpoint' on mount
- 'child' field is missing or not a map
- 'prefix' field was missing or not a string
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/fe9a49a460a9270d.
Report an issue: GitHub.