{"record":{"id":"8fa019762c0e1b25","repo":"slimtoolkit/slim","slug":"bad-input-data","errorCode":null,"errorMessage":"bad input data","messagePattern":"bad input data","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/imagebuilder/internalbuilder/engine.go","lineNumber":261,"sourceCode":"\t\t//TBD\n\t}\n\n\tid, _ := newImg.ConfigName()\n\tdigest, _ := newImg.Digest()\n\tresult := &imagebuilder.ImageResult{\n\t\tName:      options.Tags[0],\n\t\tOtherTags: otherTags,\n\t\tID:        fmt.Sprintf(\"%s:%s\", id.Algorithm, id.Hex),\n\t\tDigest:    fmt.Sprintf(\"%s:%s\", digest.Algorithm, digest.Hex),\n\t}\n\n\treturn result, nil\n}\n\nfunc layerFromTar(input imagebuilder.LayerDataInfo) (v1.Layer, error) {\n\tif !fsutil.Exists(input.Source) ||\n\t\t!fsutil.IsRegularFile(input.Source) {\n\t\treturn nil, fmt.Errorf(\"bad input data\")\n\t}\n\n\treturn tarball.LayerFromFile(input.Source)\n}\n\nfunc layerFromDir(input imagebuilder.LayerDataInfo) (v1.Layer, error) {\n\tif !fsutil.Exists(input.Source) ||\n\t\t!fsutil.IsDir(input.Source) {\n\t\treturn nil, fmt.Errorf(\"bad input data\")\n\t}\n\n\tvar b bytes.Buffer\n\ttw := tar.NewWriter(&b)\n\n\tlayerBasePath := \"/\"\n\tif input.Params != nil && input.Params.TargetPath != \"\" {\n\t\tlayerBasePath = input.Params.TargetPath\n\t}","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/imagebuilder/internalbuilder/engine.go#L243-L279","documentation":"layerFromTar validates that the LayerDataInfo.Source path exists and is a regular file before wrapping it as an OCI layer. If the path is missing or is not a plain file, it refuses to build a tar layer and returns \"bad input data\". This is a fail-fast guard so a nonexistent or directory source never reaches tarball.LayerFromFile.","triggerScenarios":"Calling Build with a layer entry whose LayerDataInfo.Source points to a file that does not exist, has been deleted before build time, or is a directory/symlink/socket rather than a regular file.","commonSituations":"Passing a wrong path in build config (typo, wrong working directory), expecting a previous build step to have produced a tarball that was never created or was cleaned up, or pointing at a directory when a tar file was required.","solutions":["Verify the Source path exists and is a regular file before calling Build (os.Stat / fsutil.Exists + IsRegularFile).","Fix the path in the build configuration or the code that produces the tar file.","Ensure any earlier pipeline step that generates the tar layer actually succeeded and wrote to Source."],"exampleFix":"// before\nbuilder.Build(ctx, layers: [{Source: \"/tmp/out/layer.tar\"}]) // file never created\n// after\nif _, err := os.Stat(\"/tmp/out/layer.tar\"); err != nil { return fmt.Errorf(\"layer tar missing: %w\", err) }\nbuilder.Build(ctx, layers: [{Source: \"/tmp/out/layer.tar\"}])","handlingStrategy":"validation","validationCode":"info, err := os.Stat(src)\nif err != nil || !info.Mode().IsRegular() {\n    return fmt.Errorf(\"layer source %q must be an existing regular file\", src)\n}","typeGuard":"func isValidTarSource(path string) bool {\n    info, err := os.Stat(path)\n    return err == nil && info.Mode().IsRegular()\n}","tryCatchPattern":"layer, err := build(ctx, opts)\nif err != nil && strings.Contains(err.Error(), \"bad input data\") {\n    // inspect/repair the layer Source path and retry\n}","preventionTips":["Stat every layer Source path before calling Build","Use absolute, cleaned paths in build config","Assert the producer step of the tar succeeded before consuming it"],"tags":["validation","image-build","bad-input"],"backgroundTag":"invalid-path-input","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}