ipfs/kubo · error
reading current MFS root: %w
Error message
reading current MFS root: %w
What it means
While collecting the old root CID for display, the local datastore Get for the MFS root key failed with an error other than datastore.ErrNotFound (which is treated as 'no previous root'). This is an unexpected datastore read failure (I/O, corruption) and aborts the root replacement before the new root is written.
Source
Thrown at core/commands/files.go:1808
fsNode, err := ft.FSNodeFromBytes(pbNode.Data())
if err != nil {
return fmt.Errorf("new root is not a valid UnixFS node: %w", err)
}
if fsNode.Type() != ft.TDirectory && fsNode.Type() != ft.THAMTShard {
return fmt.Errorf("new root must be a directory, got %s", fsNode.Type())
}
}
// Get old root for display (if exists)
var oldRootStr string
oldRootBytes, err := localDS.Get(req.Context, node.FilesRootDatastoreKey)
if err == nil {
oldRootCid, err := cid.Cast(oldRootBytes)
if err == nil {
oldRootStr = enc.Encode(oldRootCid)
}
} else if !errors.Is(err, datastore.ErrNotFound) {
return fmt.Errorf("reading current MFS root: %w", err)
}
// Write new root
err = localDS.Put(req.Context, node.FilesRootDatastoreKey, newRootCid.Bytes())
if err != nil {
return fmt.Errorf("writing new MFS root: %w", err)
}
// Build output message
newRootStr := enc.Encode(newRootCid)
var msg string
if oldRootStr != "" {
msg = fmt.Sprintf("MFS root changed from %s to %s\n", oldRootStr, newRootStr)
msg += fmt.Sprintf("The old root %s will be garbage collected unless pinned.\n", oldRootStr)
} else {
msg = fmt.Sprintf("MFS root set to %s\n", newRootStr)
}
View on GitHub (pinned to 329838acdf)
Solutions
- Check the wrapped inner error for datastore/disk issues and verify disk health and free space under IPFS_PATH.
- After fixing the underlying datastore problem, retry the root replacement; nothing was written when this error fired.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at core/commands/files.go:1808 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/83cd5bcfcd4aea2d.
Report an issue: GitHub.