{"record":{"id":"362137e3c0e48742","repo":"cloudflare/cloudflared","slug":"expected-float-found-t-for-s","errorCode":null,"errorMessage":"expected float found %T for %s","messagePattern":"expected float found %T for (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/configuration.go","lineNumber":307,"sourceCode":"func (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) {\n\tif raw, ok := c.Settings[name]; ok {\n\t\tif v, ok := raw.(float64); ok {\n\t\t\treturn v, nil\n\t\t}\n\t\treturn 0, fmt.Errorf(\"expected float found %T for %s\", raw, name)\n\t}\n\treturn 0, nil\n}\n\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))","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/config/configuration.go#L289-L325","documentation":"Type-mismatch error in configFileSettings.Float64: the named config-file setting exists but its underlying value is not a float64 (e.g. a string or bool in the YAML). The accessor refuses the wrong-typed raw value and reports the Go type it actually found.","triggerScenarios":"Calling Float64(name) on a setting stored as a string (e.g. `threshold: \"0.75\"`), bool, or int depending on the underlying decoder's behavior.","commonSituations":"Quoted floats in YAML/TOML configs; decimals written with commas; values supplied via environment/flags as strings landing in the settings map unconverted.","solutions":["Unquote the numeric value in the config file (threshold: 0.75).","Use a locale-correct decimal point (period, not comma).","If the source legitimately provides strings, read via String and strconv.ParseFloat at the call site."],"exampleFix":"// before (config.yml)\nthreshold: \"0.75\"\n// after\nthreshold: 0.75","handlingStrategy":"validation","validationCode":"// Go\ntypeAssertFloat := func(v interface{}) (float64, bool) { f, ok := v.(float64); return f, ok }","typeGuard":"func asFloat64(v interface{}) (float64, bool) { f, ok := v.(float64); return f, ok }","tryCatchPattern":"f, err := settings.Float64(\"threshold\")\nif err != nil {\n    log.Printf(\"'threshold' must be an unquoted number: %v\", err)\n    return err\n}","preventionTips":["Unquote float values in configs","Use '.' as decimal separator","Watch for YAML parsers decoding ints vs floats and normalize"],"tags":["configuration","type-mismatch","float"],"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"}