slimtoolkit/slim · error
bad input data
Error message
bad input data
What it means
layerFromTar validates that the LayerDataInfo.Source path exists and is a regular file before wrapping it as an OCI layer. If the path is missing or is not a plain file, it refuses to build a tar layer and returns "bad input data". This is a fail-fast guard so a nonexistent or directory source never reaches tarball.LayerFromFile.
Source
Thrown at pkg/imagebuilder/internalbuilder/engine.go:261
//TBD
}
id, _ := newImg.ConfigName()
digest, _ := newImg.Digest()
result := &imagebuilder.ImageResult{
Name: options.Tags[0],
OtherTags: otherTags,
ID: fmt.Sprintf("%s:%s", id.Algorithm, id.Hex),
Digest: fmt.Sprintf("%s:%s", digest.Algorithm, digest.Hex),
}
return result, nil
}
func layerFromTar(input imagebuilder.LayerDataInfo) (v1.Layer, error) {
if !fsutil.Exists(input.Source) ||
!fsutil.IsRegularFile(input.Source) {
return nil, fmt.Errorf("bad input data")
}
return tarball.LayerFromFile(input.Source)
}
func layerFromDir(input imagebuilder.LayerDataInfo) (v1.Layer, error) {
if !fsutil.Exists(input.Source) ||
!fsutil.IsDir(input.Source) {
return nil, fmt.Errorf("bad input data")
}
var b bytes.Buffer
tw := tar.NewWriter(&b)
layerBasePath := "/"
if input.Params != nil && input.Params.TargetPath != "" {
layerBasePath = input.Params.TargetPath
}View on GitHub (pinned to 81940d17fa)
Solutions
- Verify the Source path exists and is a regular file before calling Build (os.Stat / fsutil.Exists + IsRegularFile).
- Fix the path in the build configuration or the code that produces the tar file.
- Ensure any earlier pipeline step that generates the tar layer actually succeeded and wrote to Source.
Example fix
// before
builder.Build(ctx, layers: [{Source: "/tmp/out/layer.tar"}]) // file never created
// after
if _, err := os.Stat("/tmp/out/layer.tar"); err != nil { return fmt.Errorf("layer tar missing: %w", err) }
builder.Build(ctx, layers: [{Source: "/tmp/out/layer.tar"}]) Defensive patterns
Strategy: validation
Validate before calling
info, err := os.Stat(src)
if err != nil || !info.Mode().IsRegular() {
return fmt.Errorf("layer source %q must be an existing regular file", src)
} Type guard
func isValidTarSource(path string) bool {
info, err := os.Stat(path)
return err == nil && info.Mode().IsRegular()
} Try / catch
layer, err := build(ctx, opts)
if err != nil && strings.Contains(err.Error(), "bad input data") {
// inspect/repair the layer Source path and retry
} Prevention
- Stat every layer Source path before calling Build
- Use absolute, cleaned paths in build config
- Assert the producer step of the tar succeeded before consuming it
When it happens
Trigger: Calling Build with a layer entry whose LayerDataInfo.Source points to a file that does not exist, has been deleted before build time, or is a directory/symlink/socket rather than a regular file.
Common situations: Passing a wrong path in build config (typo, wrong working directory), expecting a previous build step to have produced a tarball that was never created or was cleaned up, or pointing at a directory when a tar file was required.
Related errors
AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31).
Data as JSON: /api/errors/8fa019762c0e1b25.
Report an issue: GitHub.