{"record":{"id":"fda812cbab2759a8","repo":"hyperledger/fabric","slug":"refusing-to-copy-unsupported-file-s-with-mode-o","errorCode":null,"errorMessage":"refusing to copy unsupported file %s with mode %o","messagePattern":"refusing to copy unsupported file (.+?) with mode %o","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/container/externalbuilder/copy.go","lineNumber":46,"sourceCode":"\t\t\treturn err\n\t\t}\n\t\tdestpath := filepath.Join(destroot, srcsubpath)\n\n\t\tswitch {\n\t\tcase info.IsDir():\n\t\t\treturn os.MkdirAll(destpath, info.Mode())\n\t\tcase info.Mode()&os.ModeSymlink == os.ModeSymlink:\n\t\t\t// filepath.Walk does not follow symbolic links; we need to copy\n\t\t\t// symbolic links as-is because some chaincode types (Node.js) rely\n\t\t\t// on the use of symbolic links.\n\t\t\treturn copySymlink(srcroot, path, destpath)\n\t\tcase info.Mode().IsRegular():\n\t\t\t// Intermediate directories are ensured to exist because parent\n\t\t\t// node is always visited before children in `filepath.Walk`.\n\t\t\treturn copyFile(path, destpath)\n\t\tdefault:\n\t\t\t// It's something else that we don't support copying (device, socket, etc)\n\t\t\treturn errors.Errorf(\"refusing to copy unsupported file %s with mode %o\", path, info.Mode())\n\t\t}\n\t})\n\t// If an error occurred, clean up any created files.\n\tif err != nil {\n\t\tif err := os.RemoveAll(destroot); err != nil {\n\t\t\tlogger.Errorf(\"failed to remove destination directory %s after copy error: %s\", destroot, err)\n\t\t}\n\t\treturn errors.WithMessagef(err, \"failed to copy %s to %s\", srcroot, destroot)\n\t}\n\treturn nil\n}\n\nfunc copySymlink(srcroot, srcpath, destpath string) error {\n\t// If the symlink is absolute, then we do not want to copy it.\n\tsymlinkDest, err := os.Readlink(srcpath)\n\tif err != nil {\n\t\treturn err\n\t}","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/container/externalbuilder/copy.go#L28-L64","documentation":"CopyDir walks a source directory (e.g. an external builder's release artifacts) and copies directories, regular files, and symlinks. When it encounters a filesystem node that is none of these - a device file, socket, FIFO, or other special file - it deliberately refuses to copy it and returns this error, then removes everything it already copied to the destination. This is a safety guard so special files are not silently reproduced.","triggerScenarios":"filepath.Walk over srcroot hits a node whose mode is not IsDir, not a symlink, and not IsRegular - e.g. a Unix domain socket or named pipe left inside the builder source/release directory.","commonSituations":"Build processes that leave .sock files or FIFOs in the package directory; node_modules containing sockets; dev artifacts copied into a chaincode package by mistake.","solutions":["Locate the reported path and delete it: 'find <srcroot> ! -type f ! -type d ! -type l' to find sockets/FIFOs/devices.","Clean and rebuild the chaincode package so build byproducts (sockets, pipes) are not included.","Add the offending artifact generation to a .gitignore/clean step or exclude it from the packaged source.","If the file is required, replace it with a regular file or have the build script recreate the socket at runtime."],"exampleFix":"// before: package dir contains server.sock left by a test run\n// after\n$ find . ! -type f ! -type d ! -type l -delete\n$ # repackage the chaincode","handlingStrategy":"validation","validationCode":"// shell: detect special files in a package before install\n// find <pkgdir> ! -type f ! -type d ! -type l -print\n// exit non-zero if any are found","typeGuard":null,"tryCatchPattern":"// Go caller of CopyDir\nif err := CopyDir(logger, src, dst); err != nil {\n    if strings.Contains(err.Error(), \"refusing to copy unsupported file\") {\n        // clean the reported path and re-run the build/package step\n    }\n}","preventionTips":["Run 'find ! -type f ! -type d ! -type l' over packages before installing.","Clean build outputs (sockets, FIFOs) before packaging chaincode.","Add packaging CI checks that reject special files.","Exclude runtime-generated artifacts from source packages."],"tags":["external-builder","filesystem","copy","special-files"],"backgroundTag":"unsupported-file-type-copy-refused","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}