{"record":{"id":"9a57e66767f1bdeb","repo":"slimtoolkit/slim","slug":"image-layer-data-source-path-doesnt-exist-s","errorCode":null,"errorMessage":"image layer data source path doesnt exist - %s","messagePattern":"image layer data source path doesnt exist - (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/imagebuilder/internalbuilder/engine.go","lineNumber":161,"sourceCode":"\tlog.Debug(\"DefaultSimpleBuilder.Build: config image\")\n\n\timg, err := mutate.ConfigFile(img, imgConfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar layersToAdd []v1.Layer\n\n\tfor i, layerInfo := range options.Layers {\n\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)","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/imagebuilder/internalbuilder/engine.go#L143-L179","documentation":"After confirming the Source string is non-empty, Build checks that the path actually exists on the filesystem (fsutil.Exists). If the path is missing the build fails with this error naming the offending path. Layers must be materialized on disk before building.","triggerScenarios":"Passing a LayerDataInfo.Source path that does not exist: deleted temp dirs, wrong working directory with relative paths, typoed paths, or artifacts not yet produced when Build is invoked.","commonSituations":"Building in CI where the tar artifact step failed silently or ran in a different stage/container; relative paths resolved against a different cwd; race where a temp file is cleaned up before Build runs.","solutions":["Verify the path exists before calling Build (os.Stat) and print absolute paths in errors","Convert relative paths to absolute early (filepath.Abs) with a known base directory","Ensure artifact-producing steps complete before the build step in CI pipelines","Check that cleanup routines (defer os.RemoveAll) don't remove the source before Build"],"exampleFix":"// before\nlayers = append(layers, imagebuilder.LayerDataInfo{Type: imagebuilder.TarSource, Source: \"app.tar\"})\n// after\nabs, err := filepath.Abs(\"app.tar\")\nif err != nil { return err }\nif _, err := os.Stat(abs); err != nil { return fmt.Errorf(\"layer source missing: %w\", err) }\nlayers = append(layers, imagebuilder.LayerDataInfo{Type: imagebuilder.TarSource, Source: abs})","handlingStrategy":"validation","validationCode":"for i, l := range opts.Layers {\n    if _, err := os.Stat(l.Source); err != nil {\n        return fmt.Errorf(\"layer %d source missing: %w\", i, err)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Convert all layer paths to absolute with filepath.Abs early","Ensure artifact-producing steps finish before Build in CI","Avoid removing temp layer files before the build returns"],"tags":["imagebuild","layers","filesystem","missing-file"],"backgroundTag":"file-not-found","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}