{"record":{"id":"0c60572e2bb25af0","repo":"slimtoolkit/slim","slug":"bad-parameter","errorCode":null,"errorMessage":"bad parameter","messagePattern":"bad parameter","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/docker/dockerutil/dockerutil.go","lineNumber":24,"sourceCode":"\t\"bytes\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/docker/docker/pkg/archive\"\n\tdockerapi \"github.com/fsouza/go-dockerclient\"\n\tlog \"github.com/sirupsen/logrus\"\n\n\t\"github.com/slimtoolkit/slim/pkg/docker/dockerclient\"\n\t\"github.com/slimtoolkit/slim/pkg/util/fsutil\"\n)\n\nvar (\n\tErrBadParam = errors.New(\"bad parameter\")\n\tErrNotFound = errors.New(\"not found\")\n)\n\nconst (\n\tvolumeMountPat       = \"%s:/data\"\n\tvolumeBasePath       = \"/data\"\n\temptyImageName       = \"docker-slim-empty-image:latest\"\n\temptyImageDockerfile = \"FROM scratch\\nCMD\\n\"\n)\n\ntype BasicImageProps struct {\n\tID      string\n\tSize    int64\n\tCreated int64\n}\n\ntype ImageIdentity struct {\n\tID           string","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/docker/dockerutil/dockerutil.go#L6-L42","documentation":"ErrBadParam is a sentinel error returned by dockerutil functions (HasImage, SaveImage, GetVolumeInfo, ListVolumeFiles, VolumePathExists, HasVolume) when a required argument is empty or invalid. It indicates caller misuse rather than a Docker state problem. The function refused to proceed before contacting Docker.","triggerScenarios":"Calling any of the listed dockerutil functions with an empty image name, empty volume name, or nil required option/callback parameter.","commonSituations":"An environment variable or config field holding the image/volume name is unset; a name-trimming step stripped the value; wiring bug passing the wrong variable into the helper.","solutions":["Log and validate inputs before the call: ensure image/volume names are non-empty and correctly formatted.","Check the config/env source of the name parameter for unset or blank values.","Compare the call site against the function signature to confirm arguments are in the right order.","Add unit tests that assert ErrBadParam on empty inputs to catch regressions."],"exampleFix":"// before\ndockerutil.HasImage(ctx, client, imageName) // imageName == \"\"\n// after\nif imageName == \"\" {\n    return fmt.Errorf(\"image name required\")\n}\nexists, err := dockerutil.HasImage(ctx, client, imageName)","handlingStrategy":"validation","validationCode":"func requireNonEmpty(vals ...string) error {\n    for i, v := range vals {\n        if strings.TrimSpace(v) == \"\" {\n            return fmt.Errorf(\"parameter %d is empty\", i)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"exists, err := dockerutil.HasImage(ctx, client, name)\nif errors.Is(err, dockerutil.ErrBadParam) {\n    return fmt.Errorf(\"HasImage: missing image name: %w\", err)\n}","preventionTips":["Validate image/volume names at config-load time.","Avoid bare string plumbing; wrap names in a validated type.","Trim and check env-derived values before calling dockerutil.","Add table-driven tests covering empty-parameter cases."],"tags":["parameters","validation","docker"],"backgroundTag":"missing-required-argument","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}