slimtoolkit/slim · error

bad params

Error message

bad params

What it means

ErrBadParams is returned by the linter package's Execute when required inputs are missing or inconsistent. Execute needs a valid target (a Dockerfile path or an image reference) and rejects calls where neither/both are supplied correctly. It signals misuse of the linter API rather than a lint finding.

Source

Thrown at pkg/docker/linter/linter.go:18

// Package linter implements a Dockerfile linter
package linter

import (
	"errors"
	"sync"
	"time"

	"github.com/slimtoolkit/slim/pkg/docker/dockerfile/parser"
	"github.com/slimtoolkit/slim/pkg/docker/dockerfile/spec"
	"github.com/slimtoolkit/slim/pkg/docker/dockerignore"
	"github.com/slimtoolkit/slim/pkg/docker/linter/check"

	log "github.com/sirupsen/logrus"
)

var (
	ErrBadParams = errors.New("bad params")
)

const (
	DockerfileTargetType = "dockerfile"
	ImageTargetType      = "image"
)

//TODO:
//* support incremental, partial and instruction level linting
//* support linting from string

type Options struct {
	DockerfilePath   string
	Dockerfile       *spec.Dockerfile
	SkipBuildContext bool
	BuildContextDir  string
	SkipDockerignore bool //to disable .dockerignore parsing
	Dockerignore     *dockerignore.Matcher

View on GitHub (pinned to 81940d17fa)

Solutions

  1. Ensure Execute options include a non-empty target and a supported type (DockerfileTargetType or ImageTargetType).
  2. Log the constructed options struct right before Execute to spot empty fields.
  3. Wire the CLI/config target flags into the linter options explicitly.
  4. Add a guard test asserting ErrBadParams for empty-target invocations.

Example fix

// before
linter.Execute(ctx, nil) // missing target
// after
opts := &linter.Options{TargetType: linter.DockerfileTargetType, Target: "./Dockerfile"}
err := linter.Execute(ctx, opts)
Defensive patterns

Strategy: validation

Validate before calling

if opts == nil || opts.Target == "" ||
   (opts.TargetType != linter.DockerfileTargetType && opts.TargetType != linter.ImageTargetType) {
    return linter.ErrBadParams
}

Try / catch

err := lnkr.Execute(ctx, opts)
if errors.Is(err, linter.ErrBadParams) {
    return fmt.Errorf("linter target misconfigured: %+v", opts)
}

Prevention

When it happens

Trigger: Calling linter Execute with an empty target type, empty target reference, or an unsupported target type; missing the Dockerfile path or image name fields in the options.

Common situations: CLI flag not propagated into the linter options struct; config file missing the target key; refactoring changed the target-type constant names ('dockerfile' vs 'image').

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/5e829395bef369c1. Report an issue: GitHub.