openfaas/faas · error

invalid value for max_idle_conns: %s

Error message

invalid value for max_idle_conns: %s

What it means

Thrown by ReadConfig in gateway/types/readconfig.go while parsing the gateway's environment at startup. The max_idle_conns variable must be a plain base-10 integer because it is converted with strconv.Atoi; any other content aborts configuration loading, so the gateway fails to start. When the variable is unset the default of 1024 applies, so this error only occurs when an explicit malformed value was supplied.

Source

Thrown at gateway/types/readconfig.go:149

	}

	cfg.UseBasicAuth = parseBoolValue(hasEnv.Getenv("basic_auth"))

	secretPath := hasEnv.Getenv("secret_mount_path")
	if len(secretPath) == 0 {
		secretPath = "/run/secrets/"
	}
	cfg.SecretMountPath = secretPath
	cfg.ScaleFromZero = parseBoolValue(hasEnv.Getenv("scale_from_zero"))

	cfg.MaxIdleConns = 1024
	cfg.MaxIdleConnsPerHost = 1024

	maxIdleConns := hasEnv.Getenv("max_idle_conns")
	if len(maxIdleConns) > 0 {
		val, err := strconv.Atoi(maxIdleConns)
		if err != nil {
			return nil, fmt.Errorf("invalid value for max_idle_conns: %s", maxIdleConns)
		}
		cfg.MaxIdleConns = val

	}

	maxIdleConnsPerHost := hasEnv.Getenv("max_idle_conns_per_host")
	if len(maxIdleConnsPerHost) > 0 {
		val, err := strconv.Atoi(maxIdleConnsPerHost)
		if err != nil {
			return nil, fmt.Errorf("invalid value for max_idle_conns_per_host: %s", maxIdleConnsPerHost)
		}
		cfg.MaxIdleConnsPerHost = val

	}

	cfg.AuthProxyURL = hasEnv.Getenv("auth_proxy_url")
	cfg.AuthProxyPassBody = parseBoolValue(hasEnv.Getenv("auth_proxy_pass_body"))

View on GitHub (pinned to 8d803bf9e2)

Solutions

  1. Set max_idle_conns to a bare decimal integer, e.g. max_idle_conns=512, and redeploy the gateway
  2. Remove the max_idle_conns variable to fall back to the built-in default of 1024
  3. Inspect the deployment, ConfigMap or secret for trailing whitespace, quotes, commas or unit suffixes in the value
  4. Add a CI/startup check that validates the variable against ^[0-9]+$ before shipping

Example fix

# before (docker-compose / helm env)
  max_idle_conns: "1,024"

# after
  max_idle_conns: "1024"
Defensive patterns

Strategy: validation

Validate before calling

# validate before deploying the gateway
if [ -n "$max_idle_conns" ] && ! [[ "$max_idle_conns" =~ ^[0-9]+$ ]]; then
  echo "max_idle_conns must be an integer, got: $max_idle_conns" >&2
  exit 1
fi

Type guard

func isBase10Int(s string) bool {
	_, err := strconv.Atoi(s)
	return err == nil
}

Prevention

When it happens

Trigger: Deploying the gateway with max_idle_conns set to a value strconv.Atoi cannot parse: "1024 " (trailing space or newline), "1,024", "1e3", "1024.0", "0x400" or "1k" — for example via kubectl set env, a Helm value, a docker-compose environment entry, or a ConfigMap key carrying trailing whitespace.

Common situations: YAML block scalars in ConfigMaps injecting a trailing newline; Helm chart values quoted with units or thousand separators; values copied from documentation containing commas; CI pipelines interpolating whitespace or versions into env vars.

Related errors


AI-assisted analysis of openfaas/faas@8d803bf9e2 (2026-08-16). Data as JSON: /api/errors/aca0cd1ba5d4a6a7. Report an issue: GitHub.