{"record":{"id":"5e55da454f837c8d","repo":"slimtoolkit/slim","slug":"image-layer-data-source-path-is-not-a-tar-file","errorCode":null,"errorMessage":"image layer data source path is not a tar file - %s","messagePattern":"image layer data source path is not a tar file - (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/imagebuilder/internalbuilder/engine.go","lineNumber":171,"sourceCode":"\t\tlog.Debugf(\"DefaultSimpleBuilder.Build: [%d] create image layer (type=%v source=%s)\",\n\t\t\ti, layerInfo.Type, layerInfo.Source)\n\n\t\tif layerInfo.Source == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"empty image layer data source\")\n\t\t}\n\n\t\tif !fsutil.Exists(layerInfo.Source) {\n\t\t\treturn nil, fmt.Errorf(\"image layer data source path doesnt exist - %s\", layerInfo.Source)\n\t\t}\n\n\t\tswitch layerInfo.Type {\n\t\tcase imagebuilder.TarSource:\n\t\t\tif !fsutil.IsRegularFile(layerInfo.Source) {\n\t\t\t\treturn nil, fmt.Errorf(\"image layer data source path is not a file - %s\", layerInfo.Source)\n\t\t\t}\n\n\t\t\tif !fsutil.IsTarFile(layerInfo.Source) {\n\t\t\t\treturn nil, fmt.Errorf(\"image layer data source path is not a tar file - %s\", layerInfo.Source)\n\t\t\t}\n\n\t\t\tlayer, err := layerFromTar(layerInfo)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tlayersToAdd = append(layersToAdd, layer)\n\t\tcase imagebuilder.DirSource:\n\t\t\tif !fsutil.IsDir(layerInfo.Source) {\n\t\t\t\treturn nil, fmt.Errorf(\"image layer data source path is not a directory - %s\", layerInfo.Source)\n\t\t\t}\n\n\t\t\tlayer, err := layerFromDir(layerInfo)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/imagebuilder/internalbuilder/engine.go#L153-L189","documentation":"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.","triggerScenarios":"Passing a compressed archive (.tar.gz) or arbitrary file as a TarSource layer; a corrupted/truncated tar file produced by a failed packaging step.","commonSituations":"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.","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"],"exampleFix":"// before\nlayer := imagebuilder.LayerDataInfo{Type: imagebuilder.TarSource, Source: \"/tmp/app.tar.gz\"}\n// after\n// gunzip -k /tmp/app.tar.gz  -> /tmp/app.tar\nlayer := imagebuilder.LayerDataInfo{Type: imagebuilder.TarSource, Source: \"/tmp/app.tar\"}","handlingStrategy":"validation","validationCode":"for i, l := range opts.Layers {\n    if l.Type == imagebuilder.TarSource {\n        f, err := os.Open(l.Source)\n        if err != nil { return err }\n        tr := tar.NewReader(f)\n        if _, err := tr.Next(); err != nil {\n            f.Close()\n            return fmt.Errorf(\"layer %d is not a valid tar: %s\", i, l.Source)\n        }\n        f.Close()\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["imagebuild","layers","tar","validation"],"backgroundTag":"invalid-tar-archive","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}