{"record":{"id":"1c670422d6f7c4f8","repo":"cloudflare/cloudflared","slug":"expected-int-found-t-for-v","errorCode":null,"errorMessage":"expected int, found %T for %v ","messagePattern":"expected int, found %T for (.+?) ","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/configuration.go","lineNumber":347,"sourceCode":"\t\t\t\t\treturn nil, fmt.Errorf(\"expected string, found %T for %v\", i, v)\n\t\t\t\t}\n\t\t\t\tstrSlice[i] = str\n\t\t\t}\n\t\t\treturn strSlice, nil\n\t\t}\n\t\treturn nil, fmt.Errorf(\"expected string slice found %T for %s\", raw, name)\n\t}\n\treturn nil, nil\n}\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) {","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/config/configuration.go#L329-L365","documentation":"Returned by configFileSettings.IntSlice while converting a []interface{} element to int: an element is not an int. The message has a formatting quirk (formats the value twice as %T then %v) and a trailing space; it identifies the list by name via the loop context.","triggerScenarios":"Calling IntSlice(name) on a list containing non-integer elements, e.g. `ports: [\"8080\", 80]` where a quoted string sneaks into an integer list.","commonSituations":"Quoted numbers in YAML lists; mixed lists of ints and strings; auto-generated configs where numbers were serialized as strings.","solutions":["Remove quotes so every element parses as an integer (ports: [8080, 80]).","If strings are expected, switch the consumer to StringSlice and convert with strconv.Atoi.","Trim/handle the trailing-space message when matching on error text; prefer errors-wrapping over string comparison."],"exampleFix":"// before (config.yml)\nports:\n  - \"8080\"\n  - 80\n// after\nports:\n  - 8080\n  - 80","handlingStrategy":"type-guard","validationCode":"// Go: validate all elements are ints before calling\nallInts := func(raw []interface{}) bool {\n    for _, v := range raw { if _, ok := v.(int); !ok { return false } }\n    return true\n}","typeGuard":"func asIntSlice(v interface{}) ([]int, bool) {\n    list, ok := v.([]interface{}); if !ok { return nil, false }\n    out := make([]int, len(list))\n    for i, e := range list { n, ok := e.(int); if !ok { return nil, false }; out[i] = n }\n    return out, true\n}","tryCatchPattern":"is, err := settings.IntSlice(\"ports\")\nif err != nil {\n    log.Printf(\"'ports' must be a list of unquoted ints: %v\", err)\n    return err\n}","preventionTips":["Remove quotes from numeric list elements","Keep integer lists homogeneous","Match on wrapped errors rather than the exact message text (it has a trailing space and %T/%v quirk)"],"tags":["configuration","type-mismatch","int-slice"],"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-14T00:17:10.932Z"}