{"record":{"id":"5d1e85740548fb1f","repo":"slimtoolkit/slim","slug":"image-layer-data-source-path-is-not-a-file-s","errorCode":null,"errorMessage":"image layer data source path is not a file - %s","messagePattern":"image layer data source path is not a file - (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/imagebuilder/internalbuilder/engine.go","lineNumber":167,"sourceCode":"\n\tvar layersToAdd []v1.Layer\n\n\tfor i, layerInfo := range options.Layers {\n\t\tlog.Debugf(\"DefaultSimpleBuilder.Build: [%d] create image layer (type=%v source=%s)\",\n\t\t\ti, layerInfo.Type, layerInfo.Source)\n\n\t\tif layerInfo.Source == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"empty image layer data source\")\n\t\t}\n\n\t\tif !fsutil.Exists(layerInfo.Source) {\n\t\t\treturn nil, fmt.Errorf(\"image layer data source path doesnt exist - %s\", layerInfo.Source)\n\t\t}\n\n\t\tswitch layerInfo.Type {\n\t\tcase imagebuilder.TarSource:\n\t\t\tif !fsutil.IsRegularFile(layerInfo.Source) {\n\t\t\t\treturn nil, fmt.Errorf(\"image layer data source path is not a file - %s\", layerInfo.Source)\n\t\t\t}\n\n\t\t\tif !fsutil.IsTarFile(layerInfo.Source) {\n\t\t\t\treturn nil, fmt.Errorf(\"image layer data source path is not a tar file - %s\", layerInfo.Source)\n\t\t\t}\n\n\t\t\tlayer, err := layerFromTar(layerInfo)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tlayersToAdd = append(layersToAdd, layer)\n\t\tcase imagebuilder.DirSource:\n\t\t\tif !fsutil.IsDir(layerInfo.Source) {\n\t\t\t\treturn nil, fmt.Errorf(\"image layer data source path is not a directory - %s\", layerInfo.Source)\n\t\t\t}\n\n\t\t\tlayer, err := layerFromDir(layerInfo)","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/imagebuilder/internalbuilder/engine.go#L149-L185","documentation":"For layers whose Type is imagebuilder.TarSource, Build requires the Source path to be a regular file (not a directory, symlink target, socket, etc.). fsutil.IsRegularFile fails for directories or special files, producing this error that names the path.","triggerScenarios":"Setting LayerDataInfo.Type to TarSource while Source points to a directory (or a non-regular file) and calling Engine.Build.","commonSituations":"Mixing up TarSource and DirSource: the artifact is a directory but the type was left as TarSource; paths pointing at device files or sockets; symlinked paths resolving to directories.","solutions":["Set Type to imagebuilder.DirSource when Source is a directory","Point TarSource at a regular .tar file, creating one first if needed","Check the path with os.Stat/Mode().IsRegular() before building","Fix symlink handling: resolve the path to what it actually points to"],"exampleFix":"// before\nlayer := imagebuilder.LayerDataInfo{Type: imagebuilder.TarSource, Source: \"/opt/rootfs\"} // a directory\n// after\nlayer := imagebuilder.LayerDataInfo{Type: imagebuilder.DirSource, Source: \"/opt/rootfs\"}","handlingStrategy":"validation","validationCode":"for i, l := range opts.Layers {\n    if l.Type == imagebuilder.TarSource {\n        info, err := os.Stat(l.Source)\n        if err != nil || !info.Mode().IsRegular() {\n            return fmt.Errorf(\"layer %d tar source is not a regular file: %s\", i, l.Source)\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Match Type to what the path actually is (file vs directory)","Resolve symlinks before classifying layer sources","Choose DirSource for directories instead of forcing TarSource"],"tags":["imagebuild","layers","filesystem","type-mismatch"],"backgroundTag":"file-type-mismatch","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}