{"record":{"id":"1bfa444ca0896155","repo":"weaviate/weaviate","slug":"parse-s-as-float64-w","errorCode":null,"errorMessage":"parse %s as float64: %w","messagePattern":"parse (.+?) as float64: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"usecases/config/environment.go","lineNumber":1809,"sourceCode":"}\n\nfunc parsePercentage(envName string, cb func(val float64), defaultValue float64) error {\n\treturn parseFloat64(envName, defaultValue, func(val float64) error {\n\t\tif val < 0 || val > 1 {\n\t\t\treturn fmt.Errorf(\"%s must be between 0 and 1\", envName)\n\t\t}\n\t\treturn nil\n\t}, cb)\n}\n\nfunc parseFloat64(envName string, defaultValue float64, verify func(val float64) error, cb func(val float64)) error {\n\tvar err error\n\tasFloat := defaultValue\n\n\tif v := os.Getenv(envName); v != \"\" {\n\t\tasFloat, err = strconv.ParseFloat(v, 64)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"parse %s as float64: %w\", envName, err)\n\t\t}\n\t\tif err = verify(asFloat); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tcb(asFloat)\n\treturn nil\n}\n\nfunc validatePositiveInt(val int, envName string) error {\n\tif val <= 0 {\n\t\treturn fmt.Errorf(\"%s must be an integer greater than 0. Got: %v\", envName, val)\n\t}\n\treturn nil\n}\n\nfunc validateNonNegativeInt(val int, envName string) error {","sourceCodeStart":1791,"sourceCodeEnd":1827,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/usecases/config/environment.go#L1791-L1827","documentation":"parseFloat64 parses the given env var with strconv.ParseFloat(v, 64); on failure it returns \"parse <envName> as float64: %w\". This helper underlies all float settings (including parsePercentage), so any non-numeric or malformed float string trips it.","triggerScenarios":"Setting a float env var to a locale-formatted number (\"0,5\"), a value with a unit (\"0.5%\"), or plain text.","commonSituations":"Comma decimal separators from European locales, units appended to values, YAML-style booleans where numbers were expected.","solutions":["Use a dot as the decimal separator and no units: 0.5.","Strip whitespace/quotes; note that quoted values in shell exports may keep literal quotes.","Unset the variable to use the default."],"exampleFix":"// before\nSOME_RATIO=0,5\n// after\nSOME_RATIO=0.5","handlingStrategy":"validation","validationCode":"if v := os.Getenv(envName); v != \"\" {\n  if _, err := strconv.ParseFloat(v, 64); err != nil {\n    return fmt.Errorf(\"%s must be a dot-separated float64, got %q\", envName, v)\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use '.' decimal separators; never locale commas.","Strip units and percent signs from numeric env values.","Render numbers with machine formatting (no thousands separators) in config generators."],"tags":["configuration","parsing","environment-variable"],"backgroundTag":"invalid-number-format","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}