slimtoolkit/slim · error

bad architecture value

Error message

bad architecture value

What it means

The builder validates options.ImageConfig.Architecture against a strict allow-list: empty (defaults to amd64), amd64, or arm64. Any other value returns this error before image creation. The internal engine only supports building for these two architectures.

Source

Thrown at pkg/imagebuilder/internalbuilder/engine.go:70

	if len(options.ImageConfig.Config.Entrypoint) == 0 &&
		len(options.ImageConfig.Config.Cmd) == 0 {
		return nil, fmt.Errorf("missing startup info")
	}

	if len(options.Layers) == 0 {
		return nil, fmt.Errorf("no layers")
	}

	if len(options.Layers) > 255 {
		return nil, fmt.Errorf("too many layers")
	}

	switch options.ImageConfig.Architecture {
	case "":
		options.ImageConfig.Architecture = "amd64"
	case "arm64", "amd64":
	default:
		return nil, fmt.Errorf("bad architecture value")
	}

	var img v1.Image
	if options.From == "" {
		//same as FROM scratch
		img = empty.Image
	} else {
		return nil, fmt.Errorf("custom base images are not supported yet")
	}

	imgRunConfig := v1.Config{
		User:            options.ImageConfig.Config.User,
		ExposedPorts:    options.ImageConfig.Config.ExposedPorts,
		Env:             options.ImageConfig.Config.Env,
		Entrypoint:      options.ImageConfig.Config.Entrypoint,
		Cmd:             options.ImageConfig.Config.Cmd,
		Volumes:         options.ImageConfig.Config.Volumes,
		WorkingDir:      options.ImageConfig.Config.WorkingDir,

View on GitHub (pinned to 81940d17fa)

Solutions

  1. Set ImageConfig.Architecture to "amd64" or "arm64" (or leave it empty to default to amd64)
  2. Normalize inputs: map x86_64->amd64 and aarch64->arm64 before calling Build
  3. Use lowercase values; "AMD64" is rejected
  4. If another architecture is required, extend the switch in pkg/imagebuilder/internalbuilder/engine.go:65 and use a builder that supports the target (e.g. buildx)

Example fix

// before
opts.ImageConfig.Architecture = "x86_64"
// after
arch := "x86_64"
if arch == "x86_64" { arch = "amd64" }
if arch == "aarch64" { arch = "arm64" }
opts.ImageConfig.Architecture = arch // amd64|arm64|"" only
Defensive patterns

Strategy: validation

Validate before calling

switch opts.ImageConfig.Architecture {
case "", "amd64", "arm64":
default:
    return fmt.Errorf("unsupported arch %q; use amd64 or arm64", opts.ImageConfig.Architecture)
}

Try / catch

if _, err := engine.Build(opts); err != nil {
    if strings.Contains(err.Error(), "bad architecture value") {
        opts.ImageConfig.Architecture = "amd64" // or map from runtime.GOARCH
    }
    return err
}

Prevention

When it happens

Trigger: Setting SimpleBuildOptions.ImageConfig.Architecture to values like "386", "arm", "arm/v7", "s390x", or a typo such as "AMD64"/"x86_64" and calling Build.

Common situations: Porting a Dockerfile with FROM --platform=linux/386; copying architecture strings from `uname -m` output (x86_64, aarch64) instead of the Go architecture naming; multi-arch build scripts passing unsupported platforms.

Related errors


AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31). Data as JSON: /api/errors/aac4d6c5cf010875. Report an issue: GitHub.