{"record":{"id":"e87f403bef2ca35a","repo":"ipfs/kubo","slug":"new-root-is-not-a-valid-dag-pb-node-w","errorCode":null,"errorMessage":"new root is not a valid dag-pb node: %w","messagePattern":"new root is not a valid dag-pb node: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/files.go","lineNumber":1788,"sourceCode":"\t\t\treturn fmt.Errorf(\"checking if new root exists: %w\", err)\n\t\t}\n\t\tif !hasBlock {\n\t\t\t// Special case: empty dir is always available (hardcoded in boxo)\n\t\t\temptyDirCid := ft.EmptyDirNode().Cid()\n\t\t\tif !newRootCid.Equals(emptyDirCid) {\n\t\t\t\treturn fmt.Errorf(\"new root %s does not exist locally; fetch it first with 'ipfs block get'\", enc.Encode(newRootCid))\n\t\t\t}\n\t\t}\n\n\t\t// Validate it's a directory (not a file)\n\t\tif hasBlock {\n\t\t\tblk, err := bs.Get(req.Context, newRootCid)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"reading new root block: %w\", err)\n\t\t\t}\n\t\t\tpbNode, err := dag.DecodeProtobuf(blk.RawData())\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"new root is not a valid dag-pb node: %w\", err)\n\t\t\t}\n\t\t\tfsNode, err := ft.FSNodeFromBytes(pbNode.Data())\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"new root is not a valid UnixFS node: %w\", err)\n\t\t\t}\n\t\t\tif fsNode.Type() != ft.TDirectory && fsNode.Type() != ft.THAMTShard {\n\t\t\t\treturn fmt.Errorf(\"new root must be a directory, got %s\", fsNode.Type())\n\t\t\t}\n\t\t}\n\n\t\t// Get old root for display (if exists)\n\t\tvar oldRootStr string\n\t\toldRootBytes, err := localDS.Get(req.Context, node.FilesRootDatastoreKey)\n\t\tif err == nil {\n\t\t\toldRootCid, err := cid.Cast(oldRootBytes)\n\t\t\tif err == nil {\n\t\t\t\toldRootStr = enc.Encode(oldRootCid)\n\t\t\t}","sourceCodeStart":1770,"sourceCodeEnd":1806,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/files.go#L1770-L1806","documentation":"In the MFS-root replacement flow, the new root block was fetched from the blockstore but dag.DecodeProtobuf failed to parse its raw bytes as a dag-pb node, meaning the supplied CID points at a block that is not a valid dag-pb document (e.g. a raw leaf or a UnixFS node handled one step later). The root swap is aborted before any state changes.","triggerScenarios":"Thrown at core/commands/files.go:1788 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the CID with `ipfs dag get <cid>` / `ipfs block stat` to confirm it is a dag-pb directory node.","Wrap the content properly (e.g. `ipfs add --cid-codec dag-pb` on a directory) to produce a valid directory root before retrying."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}