{"record":{"id":"a086b3fbc4c715d5","repo":"slimtoolkit/slim","slug":"image-layer-data-source-path-is-not-a-directory","errorCode":null,"errorMessage":"image layer data source path is not a directory - %s","messagePattern":"image layer data source path is not a directory - (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/imagebuilder/internalbuilder/engine.go","lineNumber":182,"sourceCode":"\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\n\t\t\tlayersToAdd = append(layersToAdd, layer)\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"unknown image data source - %v\", layerInfo.Source)\n\t\t}\n\t}\n\n\tlog.Debug(\"DefaultSimpleBuilder.Build: adding layers to image\")\n\tnewImg, err := mutate.AppendLayers(img, layersToAdd...)\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/imagebuilder/internalbuilder/engine.go#L164-L200","documentation":"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.","triggerScenarios":"Setting LayerDataInfo.Type to DirSource while Source points to a regular file, e.g. pointing at app.tar instead of the unpacked directory.","commonSituations":"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.","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"],"exampleFix":"// before\nlayer := imagebuilder.LayerDataInfo{Type: imagebuilder.DirSource, Source: \"/tmp/app.tar\"}\n// after\nlayer := imagebuilder.LayerDataInfo{Type: imagebuilder.TarSource, Source: \"/tmp/app.tar\"}\n// or use the dir: imagebuilder.LayerDataInfo{Type: imagebuilder.DirSource, Source: \"/tmp/app\"}","handlingStrategy":"validation","validationCode":"for i, l := range opts.Layers {\n    if l.Type == imagebuilder.DirSource {\n        info, err := os.Stat(l.Source)\n        if err != nil || !info.IsDir() {\n            return fmt.Errorf(\"layer %d dir source is not a directory: %s\", i, l.Source)\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["imagebuild","layers","filesystem","type-mismatch"],"backgroundTag":"file-type-mismatch","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}