{"record":{"id":"9bc9dc999477ab7c","repo":"cloudflare/cloudflared","slug":"expected-int-found-t-for-s","errorCode":null,"errorMessage":"expected int found %T for %s","messagePattern":"expected int found %T for (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/configuration.go","lineNumber":284,"sourceCode":"\tTCPKeepAlive   *CustomDuration `yaml:\"tcpKeepAlive\" json:\"tcpKeepAlive,omitempty\"`\n}\n\ntype configFileSettings struct {\n\tConfiguration `yaml:\",inline\"`\n\t// older settings will be aggregated into the generic map, should be read via cli.Context\n\tSettings map[string]interface{} `yaml:\",inline\"`\n}\n\nfunc (c *Configuration) Source() string {\n\treturn c.sourceFile\n}\n\nfunc (c *configFileSettings) Int(name string) (int, error) {\n\tif raw, ok := c.Settings[name]; ok {\n\t\tif v, ok := raw.(int); ok {\n\t\t\treturn v, nil\n\t\t}\n\t\treturn 0, fmt.Errorf(\"expected int found %T for %s\", raw, name)\n\t}\n\treturn 0, nil\n}\n\nfunc (c *configFileSettings) Duration(name string) (time.Duration, error) {\n\tif raw, ok := c.Settings[name]; ok {\n\t\tswitch v := raw.(type) {\n\t\tcase time.Duration:\n\t\t\treturn v, nil\n\t\tcase string:\n\t\t\treturn time.ParseDuration(v)\n\t\t}\n\t\treturn 0, fmt.Errorf(\"expected duration found %T for %s\", raw, name)\n\t}\n\treturn 0, nil\n}\n\nfunc (c *configFileSettings) Float64(name string) (float64, error) {","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/config/configuration.go#L266-L302","documentation":"Returned by configFileSettings.Int when a setting with the requested name exists in the parsed config file but its value is not a Go int. The error includes the actual dynamic type (%T) of the stored value, so it doubles as a type-mismatch diagnostic for YAML/TOML-parsed settings.","triggerScenarios":"Calling Int(name) on a config file setting whose underlying value is a string, bool, float64, etc. — e.g. `retries: \"5\"` (quoted number in YAML) read via Int.","commonSituations":"Quoted numbers in YAML config files; TOML/YAML parsers decoding integers as float64; users putting durations or strings where an int is expected.","solutions":["Unquote the value in the config file so it parses as an int (retries: 5 not retries: \"5\").","Check the %T in the message to see the actual type and convert the call to the matching getter (e.g. use String + strconv.Atoi, or Float64).","If values come from a format that decodes ints as float64, normalize in a custom input source before calling Int."],"exampleFix":"// before (config.yml)\nretries: \"5\"\n// after\nretries: 5","handlingStrategy":"validation","validationCode":"// Go\ntypeAssertInt := func(v interface{}) (int, bool) { i, ok := v.(int); return i, ok }","typeGuard":"func asInt(v interface{}) (int, bool) { i, ok := v.(int); return i, ok }","tryCatchPattern":"n, err := settings.Int(\"retries\")\nif err != nil {\n    log.Printf(\"setting 'retries' must be an unquoted int: %v\", err)\n    return err\n}","preventionTips":["Never quote numeric values in YAML/TOML config files","Lint config files for scalar types before deployment","Read the %T in the error to pick the right getter"],"tags":["configuration","type-mismatch","int"],"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"}