nektos/act · error

invalid value: %d. Valid memory swappiness range is 0-100

Error message

invalid value: %d. Valid memory swappiness range is 0-100

What it means

The memory swappiness option is validated to the kernel's accepted range 0-100. The sentinel -1 means 'not set' and is allowed; any other negative value or anything above 100 fails option parsing immediately. It mirrors docker run's --memory-swappiness semantics.

Source

Thrown at pkg/container/docker_cli.go:375

	if copts.macAddress != "" {
		if _, err := net.ParseMAC(strings.TrimSpace(copts.macAddress)); err != nil {
			return nil, fmt.Errorf("%s is not a valid mac address", copts.macAddress)
		}
	}
	if copts.stdin {
		attachStdin = true
	}
	// If -a is not set, attach to stdout and stderr
	if copts.attach.Len() == 0 {
		attachStdout = true
		attachStderr = true
	}

	var err error

	swappiness := copts.swappiness
	if swappiness != -1 && (swappiness < 0 || swappiness > 100) {
		return nil, fmt.Errorf("invalid value: %d. Valid memory swappiness range is 0-100", swappiness)
	}

	var binds []string
	volumes := copts.volumes.GetMap()
	// add any bind targets to the list of container volumes
	for bind := range copts.volumes.GetMap() {
		parsed, err := loader.ParseVolume(bind)
		if err != nil {
			return nil, err
		}

		if parsed.Source != "" {
			toBind := bind

			if parsed.Type == string(mount.TypeBind) {
				if hostPart, targetPath, ok := strings.Cut(bind, ":"); ok {
					if !filepath.IsAbs(hostPart) && strings.HasPrefix(hostPart, ".") {
						if absHostPart, err := filepath.Abs(hostPart); err == nil {

View on GitHub (pinned to 4f41128141)

Solutions

  1. Set the value within 0-100 (60 is the usual default)
  2. Drop --memory-swappiness entirely — modern Docker (v20+) has deprecated it anyway
  3. Double-check YAML numeric literals for stray zeros

Example fix

# before
options: --memory-swappiness 150

# after
options: --memory-swappiness 60
Defensive patterns

Strategy: validation

Validate before calling

if swappiness != -1 && (swappiness < 0 || swappiness > 100) {
    return fmt.Errorf("swappiness %d out of range 0-100", swappiness)
}

Type guard

func isValidSwappiness(v int64) bool { return v == -1 || (v >= 0 && v <= 100) }

Prevention

When it happens

Trigger: Passing --memory-swappiness (via job/container options or act's docker flag plumbing) with a value like 101, 150, or -2. The check is swappiness != -1 && (swappiness < 0 || swappiness > 100).

Common situations: Copy-pasting tuned sysctl vm.swappiness values (which can exceed 100 on some systems historically) into docker options; transposition typos (1000 instead of 100); assuming docker allows 0-200.

Related errors


AI-assisted analysis of nektos/act@4f41128141 (2026-08-15). Data as JSON: /api/errors/e1fe3db8c0617e2a. Report an issue: GitHub.