{"record":{"id":"91b50e30b58a122f","repo":"k3s-io/k3s","slug":"tar-file-entry-s-contained-unsupported-file-type","errorCode":null,"errorMessage":"tar file entry %s contained unsupported file type %v","messagePattern":"tar file entry (.+?) contained unsupported file type (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/untar/untar.go","lineNumber":123,"sourceCode":"\t\t\t\t\t// on it anywhere (the gomote push command relies\n\t\t\t\t\t// on digests only), so this is a little pointless\n\t\t\t\t\t// for now.\n\t\t\t\t\tlogrus.Printf(\"error changing modtime: %v (further Chtimes errors suppressed)\", err)\n\t\t\t\t\tloggedChtimesError = true // once is enough\n\t\t\t\t}\n\t\t\t}\n\t\t\tnFiles++\n\t\tcase mode.IsDir():\n\t\t\tif err := os.MkdirAll(abs, 0755); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tmadeDir[abs] = true\n\t\tcase f.Linkname != \"\":\n\t\t\tif err := os.Symlink(f.Linkname, abs); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"tar file entry %s contained unsupported file type %v\", f.Name, mode)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc validRelPath(p string) bool {\n\tif p == \"\" || strings.Contains(p, `\\`) || strings.HasPrefix(p, \"/\") || strings.Contains(p, \"../\") {\n\t\treturn false\n\t}\n\treturn true\n}\n","sourceCodeStart":105,"sourceCodeEnd":135,"githubUrl":"https://github.com/k3s-io/k3s/blob/6ba341e396edc16b8dcae978a7c5e3ac7ee5606e/pkg/untar/untar.go#L105-L135","documentation":"Each tar entry is dispatched on its FileInfo mode: regular files, directories, and entries with a Linkname (symlinks and hard links) are handled; anything else falls through to this error. The archive contains a device node, FIFO/named pipe, socket, or another special file type that this extractor refuses to create.","triggerScenarios":"untar.Untar on an archive including /dev entries (char/block devices), FIFOs created by a build step, or any entry whose mode is not regular/dir and whose Linkname is empty.","commonSituations":"Tarring a root filesystem or /dev wholesale; container images with device nodes baked in; build artifacts that accidentally include named pipes or sockets.","solutions":["List entry types: tar -tvf bundle.tar and look for type chars other than '-', 'd', 'l' (e.g. 'p', 'c', 'b')","Re-create the archive excluding special files, e.g. tar --exclude=/dev -C srcdir -cf bundle.tar .","If the special files are genuinely needed, extract them out-of-band with a tool that supports them, and review why they exist"],"exampleFix":"# before\ntar -cf bundle.tar /opt/app /var/run/app.fifo\n# after\ntar -C /opt/app -cf bundle.tar .  # files, dirs, symlinks only","handlingStrategy":"validation","validationCode":"func TarballHasOnlySupportedTypes(r io.Reader) error {\n\tzr, err := zstd.NewReader(r)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer zr.Close()\n\ttr := tar.NewReader(zr)\n\tfor {\n\t\th, err := tr.Next()\n\t\tif err == io.EOF {\n\t\t\treturn nil\n\t\t}\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tswitch h.Typeflag {\n\t\tcase tar.TypeReg, tar.TypeDir, tar.TypeSymlink, tar.TypeLink, tar.TypeXHeader, tar.TypeXGlobalHeader, tar.TypeGNULongName, tar.TypeGNULongLink:\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unsupported entry %q type %q\", h.Name, h.Typeflag)\n\t\t}\n\t}\n}","typeGuard":"func isSupportedTarType(tf byte) bool {\n\tswitch tf {\n\tcase tar.TypeReg, tar.TypeRegA, tar.TypeDir, tar.TypeSymlink, tar.TypeLink:\n\t\treturn true\n\t}\n\treturn false\n}","tryCatchPattern":"if err := untar.Untar(r, dir); err != nil {\n\tif strings.Contains(err.Error(), \"unsupported file type\") {\n\t\t// archive contains device nodes/FIFOs: regenerate it without special files\n\t}\n\treturn err\n}","preventionTips":["Exclude /dev and run directories when creating tars of filesystems","Run tar -tvf on new archive producers once to confirm only -, d, l entries exist","Do not bake FIFOs or device nodes into container images used with this extractor"],"tags":["go","tar","file-type","archive"],"backgroundTag":null,"analyzedSha":"6ba341e396edc16b8dcae978a7c5e3ac7ee5606e","analyzedAt":"2026-08-15T16:27:54.286Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}