slimtoolkit/slim · error
empty image layer data source
Error message
empty image layer data source
What it means
Every layer entry must point at a data source path on disk. Before creating any layer, Build checks that LayerDataInfo.Source is non-empty; an empty Source string means there is no tar file or directory to turn into an image layer, so the build aborts with this error.
Source
Thrown at pkg/imagebuilder/internalbuilder/engine.go:157
if !options.ImageConfig.Created.IsZero() {
imgConfig.Created = v1.Time{Time: options.ImageConfig.Created}
}
log.Debug("DefaultSimpleBuilder.Build: config image")
img, err := mutate.ConfigFile(img, imgConfig)
if err != nil {
return nil, err
}
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 {View on GitHub (pinned to 81940d17fa)
Solutions
- Set LayerDataInfo.Source to a valid absolute path for every layer entry
- Validate all layer entries before calling Build (skip or error on empty sources)
- Check the code that produces the layer list for empty path variables
- Log/dump the Layers slice when building to catch empty entries early
Example fix
// before
layers = append(layers, imagebuilder.LayerDataInfo{Type: imagebuilder.DirSource}) // Source missing
// after
layers = append(layers, imagebuilder.LayerDataInfo{Type: imagebuilder.DirSource, Source: "/path/to/rootfs-dir"}) Defensive patterns
Strategy: validation
Validate before calling
for i, l := range opts.Layers {
if l.Source == "" {
return fmt.Errorf("layer %d has empty Source", i)
}
} Prevention
- Validate every layer entry before calling Build
- Use named constructor helpers that require a Source argument
- Check dynamic path variables for empty values before building
When it happens
Trigger: Appending imagebuilder.LayerDataInfo to SimpleBuildOptions.Layers without setting the Source field (Type may be set, but Source is ""), then calling Engine.Build.
Common situations: Struct-literal construction where the Source field name was misspelled or simply omitted; dynamically populated layer lists where a path variable was empty due to a failed lookup; deserialized config with missing source keys.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- too many layers
- image layer data source path is not a tar file - %s
- unknown image data source - %v
- missing tags
- no layers
AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31).
Data as JSON: /api/errors/0459d45af2c9bcb5.
Report an issue: GitHub.