{"record":{"id":"6e004beaba9732ce","repo":"nats-io/nats-server","slug":"expected-float-but-got-s","errorCode":null,"errorMessage":"expected float, but got '%s'","messagePattern":"expected float, but got '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"conf/parse.go","lineNumber":356,"sourceCode":"\t\tcase \"tb\", \"ti\", \"tib\":\n\t\t\tsetValue(it, num*1024*1024*1024*1024)\n\t\tcase \"p\":\n\t\t\tsetValue(it, num*1000*1000*1000*1000*1000)\n\t\tcase \"pb\", \"pi\", \"pib\":\n\t\t\tsetValue(it, num*1024*1024*1024*1024*1024)\n\t\tcase \"e\":\n\t\t\tsetValue(it, num*1000*1000*1000*1000*1000*1000)\n\t\tcase \"eb\", \"ei\", \"eib\":\n\t\t\tsetValue(it, num*1024*1024*1024*1024*1024*1024)\n\t\t}\n\tcase itemFloat:\n\t\tnum, err := strconv.ParseFloat(it.val, 64)\n\t\tif err != nil {\n\t\t\tif e, ok := err.(*strconv.NumError); ok &&\n\t\t\t\te.Err == strconv.ErrRange {\n\t\t\t\treturn fmt.Errorf(\"float '%s' is out of the range\", it.val)\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"expected float, but got '%s'\", it.val)\n\t\t}\n\t\tsetValue(it, num)\n\tcase itemBool:\n\t\tswitch strings.ToLower(it.val) {\n\t\tcase \"true\", \"yes\", \"on\":\n\t\t\tsetValue(it, true)\n\t\tcase \"false\", \"no\", \"off\":\n\t\t\tsetValue(it, false)\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"expected boolean value, but got '%s'\", it.val)\n\t\t}\n\n\tcase itemDatetime:\n\t\tdt, err := time.Parse(\"2006-01-02T15:04:05Z\", it.val)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\n\t\t\t\t\"expected Zulu formatted DateTime, but got '%s'\", it.val)\n\t\t}","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/conf/parse.go#L338-L374","documentation":"An item classified as itemFloat could not be parsed by strconv.ParseFloat at all — the error was not ErrRange, so the literal is not a valid float syntax. The parser reports the offending text verbatim.","triggerScenarios":"processItem (from parse) reaches case itemFloat with it.val like '1,5', '1_000', '0x1f' in an unquoted context, '3.14.15', or empty text lexed as a float.","commonSituations":"Locale-formatted decimal commas, thousand separators, trailing units ('100ms', '5%'), typo'd strings where a number was expected, or a lexer misclassification.","solutions":["Correct the value to valid Go float syntax: digits with optional '.', sign, exponent (e.g. 3.14, 1e5).","Replace decimal commas with dots.","Remove units/symbols from the value; express units via the key name or a separate field.","Quote the value as a string and parse it in application code if non-standard syntax is required."],"exampleFix":"// before\nthreshold = 3,14%\n// after\nthreshold = 3.14","handlingStrategy":"validation","validationCode":"if _, err := strconv.ParseFloat(raw, 64); err != nil {\n\treturn fmt.Errorf(\"%q is not a valid float: %w\", raw, err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use dots, not commas, for decimal separators.","Keep units and symbols out of numeric config values.","Validate config values with strconv.ParseFloat in CI before deployment."],"tags":["config","parsing","float","syntax"],"backgroundTag":"invalid-number-format","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}