slimtoolkit/slim · error
image layer data source path is not a directory - %s
Error message
image layer data source path is not a directory - %s
What it means
For layers whose Type is imagebuilder.DirSource, Build requires Source to be a directory. If the path is a regular file or other non-directory entry, fsutil.IsDir fails and the build returns this error naming the path.
Source
Thrown at pkg/imagebuilder/internalbuilder/engine.go:182
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)
if err != nil {
return nil, err
}
layersToAdd = append(layersToAdd, layer)
default:
return nil, fmt.Errorf("unknown image data source - %v", layerInfo.Source)
}
}
log.Debug("DefaultSimpleBuilder.Build: adding layers to image")
newImg, err := mutate.AppendLayers(img, layersToAdd...)
if err != nil {
return nil, err
}View on GitHub (pinned to 81940d17fa)
Solutions
- Set Type to imagebuilder.TarSource when Source is a file
- Point DirSource at the actual directory containing the layer contents
- Create the directory if it was expected but missing
- Validate with os.Stat and info.IsDir() before calling Build
Example fix
// before
layer := imagebuilder.LayerDataInfo{Type: imagebuilder.DirSource, Source: "/tmp/app.tar"}
// after
layer := imagebuilder.LayerDataInfo{Type: imagebuilder.TarSource, Source: "/tmp/app.tar"}
// or use the dir: imagebuilder.LayerDataInfo{Type: imagebuilder.DirSource, Source: "/tmp/app"} Defensive patterns
Strategy: validation
Validate before calling
for i, l := range opts.Layers {
if l.Type == imagebuilder.DirSource {
info, err := os.Stat(l.Source)
if err != nil || !info.IsDir() {
return fmt.Errorf("layer %d dir source is not a directory: %s", i, l.Source)
}
}
} Prevention
- Use TarSource for files, DirSource for directories — keep them consistent
- Create expected directories before building
- Validate layer entries with os.Stat in a pre-build step
When it happens
Trigger: Setting LayerDataInfo.Type to DirSource while Source points to a regular file, e.g. pointing at app.tar instead of the unpacked directory.
Common situations: Swapped TarSource/DirSource types; the directory was replaced by a file (or never created and a file of the same name exists); config where the source root points at a single artifact file.
Related errors
- image layer data source path is not a file - %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/a086b3fbc4c715d5.
Report an issue: GitHub.