{"record":{"id":"aeeca191142c9610","repo":"cloudflare/cloudflared","slug":"expected-string-found-t-for-v","errorCode":null,"errorMessage":"expected string, found %T for %v","messagePattern":"expected string, found %T for (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/configuration.go","lineNumber":329,"sourceCode":"\nfunc (c *configFileSettings) String(name string) (string, error) {\n\tif raw, ok := c.Settings[name]; ok {\n\t\tif v, ok := raw.(string); ok {\n\t\t\treturn v, nil\n\t\t}\n\t\treturn \"\", fmt.Errorf(\"expected string found %T for %s\", raw, name)\n\t}\n\treturn \"\", nil\n}\n\nfunc (c *configFileSettings) StringSlice(name string) ([]string, error) {\n\tif raw, ok := c.Settings[name]; ok {\n\t\tif slice, ok := raw.([]interface{}); ok {\n\t\t\tstrSlice := make([]string, len(slice))\n\t\t\tfor i, v := range slice {\n\t\t\t\tstr, ok := v.(string)\n\t\t\t\tif !ok {\n\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)","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/config/configuration.go#L311-L347","documentation":"Returned by configFileSettings.StringSlice while converting a []interface{} element to string: an element inside the slice is not a string. Note the message formats `i` (the index) as %T and the value `v` as %v, so the message actually prints 'int' (the type of the index) rather than the element's type — a known formatting bug in the error text.","triggerScenarios":"Calling StringSlice(name) on a list where at least one element is not a string, e.g. `origins: [8080, \"web\"]` in YAML.","commonSituations":"Mixed-type YAML lists; numeric ports or booleans inside string lists; hand-edited config files.","solutions":["Make every element of the list a string in the config file (quote numeric entries).","Note the message shows the index position, not the element type — check that element of the list.","Handle the error at the call site by falling back to per-element conversion if mixed types are expected."],"exampleFix":"// before (config.yml)\norigins:\n  - 8080\n  - web\n// after\norigins:\n  - \"8080\"\n  - web","handlingStrategy":"type-guard","validationCode":"// Go: validate all elements are strings before calling\nallStrings := func(raw []interface{}) bool {\n    for _, v := range raw { if _, ok := v.(string); !ok { return false } }\n    return true\n}","typeGuard":"func asStringSlice(v interface{}) ([]string, bool) {\n    list, ok := v.([]interface{}); if !ok { return nil, false }\n    out := make([]string, len(list))\n    for i, e := range list { s, ok := e.(string); if !ok { return nil, false }; out[i] = s }\n    return out, true\n}","tryCatchPattern":"ss, err := settings.StringSlice(\"origins\")\nif err != nil {\n    log.Printf(\"'origins' must be a list of strings: %v\", err)\n    return err\n}","preventionTips":["Quote numeric/boolean elements inside string lists","Keep lists homogeneous in type","Remember this error text reports the index, not the element type — inspect the element at that index"],"tags":["configuration","type-mismatch","string-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"}