{"record":{"id":"cb60922b108eca23","repo":"ipfs/kubo","slug":"unknown-file-type","errorCode":null,"errorMessage":"unknown file type","messagePattern":"unknown file type","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/coreunix/add.go","lineNumber":431,"sourceCode":"\t\t\treturn err\n\t\t}\n\t\tif err := mr.FlushMemFree(adder.ctx); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tadder.liveNodes = 0\n\t}\n\tadder.liveNodes++\n\n\tswitch f := file.(type) {\n\tcase files.Directory:\n\t\treturn adder.addDir(ctx, path, f, toplevel)\n\tcase *files.Symlink:\n\t\treturn adder.addSymlink(ctx, path, f)\n\tcase files.File:\n\t\treturn adder.addFile(path, f)\n\tdefault:\n\t\treturn errors.New(\"unknown file type\")\n\t}\n}\n\nfunc (adder *Adder) addSymlink(ctx context.Context, path string, l *files.Symlink) error {\n\tsdata, err := unixfs.SymlinkData(l.Target)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif !adder.FileMtime.IsZero() {\n\t\tfsn, err := unixfs.FSNodeFromBytes(sdata)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfsn.SetModTime(adder.FileMtime)\n\t\tif sdata, err = fsn.GetBytes(); err != nil {\n\t\t\treturn err","sourceCodeStart":413,"sourceCodeEnd":449,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/coreunix/add.go#L413-L449","documentation":"Adder's node dispatcher handles the concrete files.Node kinds it supports: directories (addDir), symlinks (addSymlink), and files (addFile). Any files.Node that implements the interface but matches none of these concrete types falls to the default branch, which fails with 'unknown file type'. It guards the importer against being handed node kinds coreunix cannot serialize into UnixFS.","triggerScenarios":"Calling AddAllAndPin / Add with a files.Node implementation that is none of *files.Symlink, files.File, or files.Directory (note files.File is a value type here, so non-pointer or custom File implementations matching the interface are handled, but novel custom kinds are not).","commonSituations":"Custom files.Node types from application code; type mismatches from mixing go-ipfs-files and go-libipfs/files packages so the type switch misses; passing a files.Directory stored in an interface the switch does not reach (nil or wrapper types).","solutions":["Convert unsupported node types to files.File (bytes) or files.Directory (map/slice) before importing","Ensure all files types come from one import path consistent with the kubo version in use","Upgrade coreunix/go-libipfs if a newly supported files kind (e.g. a new special node) is required","Log/debug the concrete type of the offending node (fmt.Sprintf(\"%T\")) and implement a wrapper exposing it as a supported kind"],"exampleFix":"// before: custom node type\ntype dirNode struct{ files.Node }\nadder.AddAllAndPin(ctx, dirNode{}, false) // unknown file type\n// after: map it to a known kind\nentries := map[string]files.Node{\"a.txt\": files.NewBytesFile([]byte(\"a\"))}\nroot := files.NewMapFile(\"\", \"\", entries)\nadder.AddAllAndPin(ctx, root, false)","handlingStrategy":"type-guard","validationCode":"switch n.(type) {\ncase files.File, *files.Symlink, files.Directory:\n\t// ok\ndefault:\n\treturn fmt.Errorf(\"cannot import node of type %T\", n)\n}","typeGuard":"func isAddable(n files.Node) bool {\n\tswitch n.(type) {\n\tcase files.File, *files.Symlink, files.Directory:\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}","tryCatchPattern":"if err := adder.AddAllAndPin(ctx, node, false); err != nil {\n\tif err.Error() == \"unknown file type\" {\n\t\treturn fmt.Errorf(\"node %T must be converted to File/Directory/Symlink\", node)\n\t}\n\treturn err\n}","preventionTips":["Validate the files tree with a walker before passing it to the Adder","Avoid custom files.Node implementations in importer inputs","Keep files package imports from one module version","When reading user directories with files.NewSerialFile, special file types (sockets, devices) may surface as unsupported kinds — filter them first"],"tags":["unixfs","add","file-type","importer"],"backgroundTag":"unrecognized-node-type","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"}