slimtoolkit/slim · error
image layer data source path is not a tar file - %s
Error message
image layer data source path is not a tar file - %s
What it means
For TarSource layers, after confirming the path is a regular file, Build verifies the file is a valid tar archive using fsutil.IsTarFile. A regular file that is not a tar (e.g. plain binary, gzip-only stream mislabeled, truncated tar) triggers this error.
Source
Thrown at pkg/imagebuilder/internalbuilder/engine.go:171
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)
if err != nil {
return nil, err
}
View on GitHub (pinned to 81940d17fa)
Solutions
- Supply an uncompressed, valid tar archive (tar -cf layer.tar dir/)
- If the data is .tar.gz, decompress it to a plain .tar first or use DirSource on the unpacked directory
- Verify with tar -tf layer.tar before building
- Regenerate a corrupted tar from the original files
Example fix
// before
layer := imagebuilder.LayerDataInfo{Type: imagebuilder.TarSource, Source: "/tmp/app.tar.gz"}
// after
// gunzip -k /tmp/app.tar.gz -> /tmp/app.tar
layer := imagebuilder.LayerDataInfo{Type: imagebuilder.TarSource, Source: "/tmp/app.tar"} Defensive patterns
Strategy: validation
Validate before calling
for i, l := range opts.Layers {
if l.Type == imagebuilder.TarSource {
f, err := os.Open(l.Source)
if err != nil { return err }
tr := tar.NewReader(f)
if _, err := tr.Next(); err != nil {
f.Close()
return fmt.Errorf("layer %d is not a valid tar: %s", i, l.Source)
}
f.Close()
}
} Prevention
- Only pass uncompressed tar archives as TarSource
- Run tar -tf on artifacts in CI before building
- Regenerate tars from original files if packaging may have been interrupted
When it happens
Trigger: Passing a compressed archive (.tar.gz) or arbitrary file as a TarSource layer; a corrupted/truncated tar file produced by a failed packaging step.
Common situations: Pointing Source at app.tar.gz or a binary instead of an uncompressed tar; packaging script crashed mid-write leaving a partial tar; confusing docker-save output with layer tars.
Related errors
- too many layers
- empty image layer data source
- unknown image data source - %v
- no layers
- bad architecture value
AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31).
Data as JSON: /api/errors/5e55da454f837c8d.
Report an issue: GitHub.