slimtoolkit/slim · error
image layer data source path is not a file - %s
Error message
image layer data source path is not a file - %s
What it means
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.
Source
Thrown at pkg/imagebuilder/internalbuilder/engine.go:167
var layersToAdd []v1.Layer
for i, layerInfo := range options.Layers {
log.Debugf("DefaultSimpleBuilder.Build: [%d] create image layer (type=%v source=%s)",
i, layerInfo.Type, layerInfo.Source)
if layerInfo.Source == "" {
return nil, fmt.Errorf("empty image layer data source")
}
if !fsutil.Exists(layerInfo.Source) {
return nil, fmt.Errorf("image layer data source path doesnt exist - %s", layerInfo.Source)
}
switch layerInfo.Type {
case imagebuilder.TarSource:
if !fsutil.IsRegularFile(layerInfo.Source) {
return nil, fmt.Errorf("image layer data source path is not a file - %s", layerInfo.Source)
}
if !fsutil.IsTarFile(layerInfo.Source) {
return nil, fmt.Errorf("image layer data source path is not a tar file - %s", layerInfo.Source)
}
layer, err := layerFromTar(layerInfo)
if err != nil {
return nil, err
}
layersToAdd = append(layersToAdd, layer)
case imagebuilder.DirSource:
if !fsutil.IsDir(layerInfo.Source) {
return nil, fmt.Errorf("image layer data source path is not a directory - %s", layerInfo.Source)
}
layer, err := layerFromDir(layerInfo)View on GitHub (pinned to 81940d17fa)
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
Example fix
// before
layer := imagebuilder.LayerDataInfo{Type: imagebuilder.TarSource, Source: "/opt/rootfs"} // a directory
// after
layer := imagebuilder.LayerDataInfo{Type: imagebuilder.DirSource, Source: "/opt/rootfs"} Defensive patterns
Strategy: validation
Validate before calling
for i, l := range opts.Layers {
if l.Type == imagebuilder.TarSource {
info, err := os.Stat(l.Source)
if err != nil || !info.Mode().IsRegular() {
return fmt.Errorf("layer %d tar source is not a regular file: %s", i, l.Source)
}
}
} Prevention
- 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
When it happens
Trigger: Setting LayerDataInfo.Type to TarSource while Source points to a directory (or a non-regular file) and calling Engine.Build.
Common situations: 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.
Related errors
- image layer data source path is not a directory - %s
- image layer data source path doesnt exist - %s
- too many layers
- empty image layer data source
- image layer data source path is not a tar file - %s
AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31).
Data as JSON: /api/errors/5d1e85740548fb1f.
Report an issue: GitHub.