slimtoolkit/slim · error
bad parameter
Error message
bad parameter
What it means
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.
Source
Thrown at pkg/docker/dockerutil/dockerutil.go:24
"bytes"
"errors"
"fmt"
"io"
"os"
"path/filepath"
"strings"
"time"
"github.com/docker/docker/pkg/archive"
dockerapi "github.com/fsouza/go-dockerclient"
log "github.com/sirupsen/logrus"
"github.com/slimtoolkit/slim/pkg/docker/dockerclient"
"github.com/slimtoolkit/slim/pkg/util/fsutil"
)
var (
ErrBadParam = errors.New("bad parameter")
ErrNotFound = errors.New("not found")
)
const (
volumeMountPat = "%s:/data"
volumeBasePath = "/data"
emptyImageName = "docker-slim-empty-image:latest"
emptyImageDockerfile = "FROM scratch\nCMD\n"
)
type BasicImageProps struct {
ID string
Size int64
Created int64
}
type ImageIdentity struct {
ID stringView on GitHub (pinned to 81940d17fa)
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.
Example fix
// before
dockerutil.HasImage(ctx, client, imageName) // imageName == ""
// after
if imageName == "" {
return fmt.Errorf("image name required")
}
exists, err := dockerutil.HasImage(ctx, client, imageName) Defensive patterns
Strategy: validation
Validate before calling
func requireNonEmpty(vals ...string) error {
for i, v := range vals {
if strings.TrimSpace(v) == "" {
return fmt.Errorf("parameter %d is empty", i)
}
}
return nil
} Try / catch
exists, err := dockerutil.HasImage(ctx, client, name)
if errors.Is(err, dockerutil.ErrBadParam) {
return fmt.Errorf("HasImage: missing image name: %w", err)
} Prevention
- 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.
When it happens
Trigger: Calling any of the listed dockerutil functions with an empty image name, empty volume name, or nil required option/callback parameter.
Common situations: 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.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31).
Data as JSON: /api/errors/0c60572e2bb25af0.
Report an issue: GitHub.