cloudflare/cloudflared · error
expected boolean found %T for %s
Error message
expected boolean found %T for %s
What it means
configFileSettings.Bool reads a named setting from the YAML config file and expects a Go bool (YAML true/false). If the key exists but holds any other type (string "true", int 1, etc.), cloudflared returns `expected boolean found %T` naming the actual type. Boolean flags set in the config file must be real YAML booleans, not quoted strings.
Source
Thrown at config/configuration.go:370
}
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
}
var configuration configFileSettings
func GetConfiguration() *Configuration {
return &configuration.Configuration
}
// ReadConfigFile returns InputSourceContext initialized from the configuration file.
// On repeat calls returns with the same file, returns without reading the file again; however,
// if value of "config" flag changes, will read the new config file
func ReadConfigFile(c *cli.Context, log *zerolog.Logger) (settings *configFileSettings, warnings string, err error) {
configFile := c.String("config")
if configuration.Source() == configFile || configFile == "" {
if configuration.Source() == "" {
return nil, "", ErrNoConfigFileView on GitHub (pinned to 2253eeeb25)
Solutions
- Edit the config file so the value is an unquoted YAML boolean: `flag: true`
- Remove quotes around true/false values
- If the value came from environment substitution, ensure the substituted text is bare true/false
- Re-run cloudflared with the fixed config file
Example fix
# before (config.yml) hello-world: "true" # after hello-world: true
Defensive patterns
Strategy: validation
Validate before calling
raw, ok := cfg["boolFlag"]
if ok { if _, isBool := raw.(bool); !isBool { return fmt.Errorf("boolFlag must be bare true/false, got %T", raw) } } Type guard
func isYAMLBool(v interface{}) bool { _, ok := v.(bool); return ok } Prevention
- Use bare true/false (no quotes) for boolean flags in config.yml
- Avoid injecting boolean values via env substitution that could quote them
- Don't copy CLI --flag=true syntax into YAML
When it happens
Trigger: A boolean flag (e.g. `hello-world: true`, `url: ...` style toggles) is present in c.Settings but its value is a string like "true", a number, or a nested map, when the CLI bool accessor is called during config resolution.
Common situations: Writing `flag: "true"` (quoted) in config.yml, using `flag: yes` with a YAML parser configured oddly, or copying CLI-style `--flag=true` text into the config file.
Related errors
- expected int slice found %T for %s
- --unix-socket must be used exclusively.
- Specified origin urls using both --url and argument. Decide
- option type Generic not supported
- unable to find config file
AI-assisted analysis of cloudflare/cloudflared@2253eeeb25 (2026-09-06).
Data as JSON: /api/errors/ad8bccf636ec45cd.
Report an issue: GitHub.