{"record":{"id":"830ad2e262829aff","repo":"cloudflare/cloudflared","slug":"expected-int-slice-found-t-for-s","errorCode":null,"errorMessage":"expected int slice found %T for %s","messagePattern":"expected int slice found %T for (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/configuration.go","lineNumber":356,"sourceCode":"}\n\nfunc (c *configFileSettings) IntSlice(name string) ([]int, error) {\n\tif raw, ok := c.Settings[name]; ok {\n\t\tif slice, ok := raw.([]interface{}); ok {\n\t\t\tintSlice := make([]int, len(slice))\n\t\t\tfor i, v := range slice {\n\t\t\t\tstr, ok := v.(int)\n\t\t\t\tif !ok {\n\t\t\t\t\treturn nil, fmt.Errorf(\"expected int, found %T for %v \", v, v)\n\t\t\t\t}\n\t\t\t\tintSlice[i] = str\n\t\t\t}\n\t\t\treturn intSlice, nil\n\t\t}\n\t\tif v, ok := raw.([]int); ok {\n\t\t\treturn v, nil\n\t\t}\n\t\treturn nil, fmt.Errorf(\"expected int slice found %T for %s\", raw, name)\n\t}\n\treturn nil, nil\n}\n\nfunc (c *configFileSettings) Generic(name string) (cli.Generic, error) {\n\treturn nil, errors.New(\"option type Generic not supported\")\n}\n\nfunc (c *configFileSettings) Bool(name string) (bool, error) {\n\tif raw, ok := c.Settings[name]; ok {\n\t\tif v, ok := raw.(bool); ok {\n\t\t\treturn v, nil\n\t\t}\n\t\treturn false, fmt.Errorf(\"expected boolean found %T for %s\", raw, name)\n\t}\n\treturn false, nil\n}\n","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/config/configuration.go#L338-L374","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Edit the config file so the setting is an unquoted YAML list of integers, e.g. `key: [8080, 8081]`","Remove surrounding quotes from list elements so YAML parses them as numbers, not strings","If a single scalar was intended, verify the flag actually accepts a scalar or wrap it in a list","Run `cloudflared --config <file> ...` again after fixing to confirm the value parses"],"exampleFix":"# before (config.yml)\noriginRequest:\n  connectTimeout: \"5000\"\n# after\noriginRequest:\n  someIntSliceFlag: [5000, 5001]","handlingStrategy":"validation","validationCode":"// Before running cloudflared, validate the config value is an int list:\nval := cfg[\"someIntSliceFlag\"]\nlist, ok := val.([]interface{})\nif !ok { return fmt.Errorf(\"%T is not a list\", val) }\nfor _, e := range list { if _, ok := e.(int); !ok { return fmt.Errorf(\"element %v is not an int\", e) } }","typeGuard":"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 }","tryCatchPattern":null,"preventionTips":["Write int-slice settings as unquoted YAML lists of integers: [8080, 8081]","Never quote numeric list elements in config.yml","Validate config with cloudflared before deploying (run the command once with the config)"],"tags":["config","type-mismatch","yaml"],"backgroundTag":"config-type-mismatch","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}