nektos/act · error

%s is not a valid mac address

Error message

%s is not a valid mac address

What it means

During parsing of container run options (docker CLI-compatible flag surface vendored into act's pkg/container), the --mac-address value is validated with net.ParseMAC. If it does not match any MAC notation (aa:bb:cc:dd:ee:ff, aa-bb-cc-dd-ee-ff, or dotted forms), this error returns and container creation aborts before reaching the Docker daemon.

Source

Thrown at pkg/container/docker_cli.go:359

	NetworkingConfig *network.NetworkingConfig
}

// parse parses the args for the specified command and generates a Config,
// a HostConfig and returns them with the specified command.
// If the specified args are not valid, it will return an error.
//
//nolint:gocyclo
func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*containerConfig, error) {
	var (
		attachStdin  = copts.attach.Get("stdin")
		attachStdout = copts.attach.Get("stdout")
		attachStderr = copts.attach.Get("stderr")
	)

	// Validate the input mac address
	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)
	}

View on GitHub (pinned to 4f41128141)

Solutions

  1. Correct the value to full 48-bit form, e.g. --mac-address 02:42:ac:11:ff:ee
  2. Remove --mac-address if it is not actually required for the test
  3. Validate with a quick echo check or an online MAC regex before committing the workflow

Example fix

# before
options: --mac-address 00:11:22:33:44

# after
options: --mac-address 00:11:22:33:44:55
Defensive patterns

Strategy: validation

Validate before calling

// pre-validate any MAC used in options
if macAddr != "" {
    if _, err := net.ParseMAC(strings.TrimSpace(macAddr)); err != nil {
        return fmt.Errorf("option mac-address %q invalid", macAddr)
    }
}

Type guard

func isValidMAC(s string) bool {
    _, err := net.ParseMAC(strings.TrimSpace(s))
    return err == nil
}

Prevention

When it happens

Trigger: Passing --container-mac-address / mac_address in job or container options (e.g. options: --mac-address 00:11:22:33:44) with a wrong separator, too few octets, hex typos, or non-hex characters. TrimSpace is applied, but surrounding format errors still fail.

Common situations: Copy-pasted MACs with a missing octet; using '-' separators with wrong grouping like '00-11-22-33-44'; DHCP-mac-pinning workflows run under act; typos in workflow YAML options strings.

Related errors


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