{"record":{"id":"0459d45af2c9bcb5","repo":"slimtoolkit/slim","slug":"empty-image-layer-data-source","errorCode":null,"errorMessage":"empty image layer data source","messagePattern":"empty image layer data source","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/imagebuilder/internalbuilder/engine.go","lineNumber":157,"sourceCode":"\tif !options.ImageConfig.Created.IsZero() {\n\t\timgConfig.Created = v1.Time{Time: options.ImageConfig.Created}\n\t}\n\n\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 {","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/imagebuilder/internalbuilder/engine.go#L139-L175","documentation":"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.","triggerScenarios":"Appending imagebuilder.LayerDataInfo to SimpleBuildOptions.Layers without setting the Source field (Type may be set, but Source is \"\"), then calling Engine.Build.","commonSituations":"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.","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"],"exampleFix":"// before\nlayers = append(layers, imagebuilder.LayerDataInfo{Type: imagebuilder.DirSource}) // Source missing\n// after\nlayers = append(layers, imagebuilder.LayerDataInfo{Type: imagebuilder.DirSource, Source: \"/path/to/rootfs-dir\"})","handlingStrategy":"validation","validationCode":"for i, l := range opts.Layers {\n    if l.Source == \"\" {\n        return fmt.Errorf(\"layer %d has empty Source\", i)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["imagebuild","layers","validation","missing-field"],"backgroundTag":"missing-required-argument","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}