cloudflare/cloudflared · error

expected int slice found %T for %s

Error message

expected int slice found %T for %s

What it means

configFileSettings.IntSlice reads a named setting from the YAML config file and expects its value to be either a []int or a []interface{} of numbers. If the raw parsed value is neither, cloudflared throws `expected int slice found %T` to report the actual Go type found for that setting key. It guards against config files where a slice-of-int flag is set to a string, bool, or a list of strings.

Source

Thrown at config/configuration.go:356

}

func (c *configFileSettings) IntSlice(name string) ([]int, error) {
	if raw, ok := c.Settings[name]; ok {
		if slice, ok := raw.([]interface{}); ok {
			intSlice := make([]int, len(slice))
			for i, v := range slice {
				str, ok := v.(int)
				if !ok {
					return nil, fmt.Errorf("expected int, found %T for %v ", v, v)
				}
				intSlice[i] = str
			}
			return intSlice, nil
		}
		if v, ok := raw.([]int); ok {
			return v, nil
		}
		return nil, fmt.Errorf("expected int slice found %T for %s", raw, name)
	}
	return nil, nil
}

func (c *configFileSettings) Generic(name string) (cli.Generic, error) {
	return nil, errors.New("option type Generic not supported")
}

func (c *configFileSettings) Bool(name string) (bool, error) {
	if raw, ok := c.Settings[name]; ok {
		if v, ok := raw.(bool); ok {
			return v, nil
		}
		return false, fmt.Errorf("expected boolean found %T for %s", raw, name)
	}
	return false, nil
}

View on GitHub (pinned to 2253eeeb25)

Solutions

  1. Edit the config file so the setting is an unquoted YAML list of integers, e.g. `key: [8080, 8081]`
  2. Remove surrounding quotes from list elements so YAML parses them as numbers, not strings
  3. If a single scalar was intended, verify the flag actually accepts a scalar or wrap it in a list
  4. Run `cloudflared --config <file> ...` again after fixing to confirm the value parses

Example fix

# before (config.yml)
originRequest:
  connectTimeout: "5000"
# after
originRequest:
  someIntSliceFlag: [5000, 5001]
Defensive patterns

Strategy: validation

Validate before calling

// Before running cloudflared, validate the config value is an int list:
val := cfg["someIntSliceFlag"]
list, ok := val.([]interface{})
if !ok { return fmt.Errorf("%T is not a list", val) }
for _, e := range list { if _, ok := e.(int); !ok { return fmt.Errorf("element %v is not an int", e) } }

Type guard

func isIntSlice(v interface{}) bool { l, ok := v.([]interface{}); if !ok { _, ok = v.([]int); return ok }; for _, e := range l { if _, ok := e.(int); !ok { return false } }; return true }

Prevention

When it happens

Trigger: Called via cli.Context APIs during config loading when a flag (e.g. an int-slice flag like region or similar) is set in the YAML config file with a value that does not unmarshal to []int, e.g. a string, a bool, or a list of non-numeric strings.

Common situations: Users quoting values in YAML (`key: "1, 2"` instead of `key: [1, 2]`), writing a list of quoted numbers (`["8080", "8081"]`), or pointing an int-slice flag at a scalar value in ~/.cloudflared/config.yml.

Related errors


AI-assisted analysis of cloudflare/cloudflared@2253eeeb25 (2026-09-06). Data as JSON: /api/errors/830ad2e262829aff. Report an issue: GitHub.