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           string

View on GitHub (pinned to 81940d17fa)

Solutions

  1. Log and validate inputs before the call: ensure image/volume names are non-empty and correctly formatted.
  2. Check the config/env source of the name parameter for unset or blank values.
  3. Compare the call site against the function signature to confirm arguments are in the right order.
  4. 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

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.