{"record":{"id":"a809caf6e09cbc67","repo":"slimtoolkit/slim","slug":"unknown-image-data-source-v","errorCode":null,"errorMessage":"unknown image data source - %v","messagePattern":"unknown image data source - (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/imagebuilder/internalbuilder/engine.go","lineNumber":192,"sourceCode":"\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}\n\n\tif len(options.Tags) == 0 {\n\t\treturn nil, fmt.Errorf(\"missing tags\")\n\t}\n\n\ttag, err := name.NewTag(options.Tags[0])\n\tif err != nil {\n\t\treturn nil, err\n\t}\n","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/imagebuilder/internalbuilder/engine.go#L174-L210","documentation":"The layer Type switch only accepts imagebuilder.TarSource and imagebuilder.DirSource; any other value hits the default branch and aborts with this error. Notably the message prints layerInfo.Source (not the Type), so the printed value may look odd — the real problem is an unrecognized Type constant.","triggerScenarios":"Setting LayerDataInfo.Type to an undefined/zero value, a type from a different package, or a custom string; constructing LayerDataInfo without initializing Type.","commonSituations":"Zero-value structs (Type \"\") where Source was set but Type forgotten; renaming or hand-writing type strings instead of using imagebuilder.TarSource/DirSource constants; version drift between producer and builder code.","solutions":["Set Type to imagebuilder.TarSource or imagebuilder.DirSource explicitly for every layer","Check for zero-value LayerDataInfo structs missing Type initialization","Always use the exported constants rather than literal strings","If the message value is a valid path, inspect the Type field — the error prints Source, not Type"],"exampleFix":"// before\nlayers = append(layers, imagebuilder.LayerDataInfo{Source: \"/tmp/rootfs\"}) // Type is zero value\n// after\nlayers = append(layers, imagebuilder.LayerDataInfo{Type: imagebuilder.DirSource, Source: \"/tmp/rootfs\"})","handlingStrategy":"validation","validationCode":"for i, l := range opts.Layers {\n    switch l.Type {\n    case imagebuilder.TarSource, imagebuilder.DirSource:\n    default:\n        return fmt.Errorf(\"layer %d has unknown Type %q\", i, l.Type)\n    }\n}","typeGuard":null,"tryCatchPattern":"if _, err := engine.Build(opts); err != nil {\n    if strings.Contains(err.Error(), \"unknown image data source\") {\n        // inspect each layer's Type; note the error prints Source, not Type\n    }\n    return err\n}","preventionTips":["Always initialize LayerDataInfo.Type with the exported constants","Avoid constructing LayerDataInfo as a bare zero-value struct literal","Add a pre-build sweep that rejects layers with empty/unknown Type"],"tags":["imagebuild","layers","enum","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}