{"record":{"id":"6ecb1955e010a3bd","repo":"wavetermdev/waveterm","slug":"invalid-number-for-float64-s","errorCode":null,"errorMessage":"invalid number for float64: %s","messagePattern":"invalid number for float64: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wconfig/settingsconfig.go","lineNumber":837,"sourceCode":"var dummyNumber json.Number\n\nfunc convertJsonNumber(num json.Number, ctype reflect.Type) (interface{}, error) {\n\t// ctype might be int64, float64, string, *int64, *float64, *string\n\t// switch on ctype first\n\tif ctype.Kind() == reflect.Pointer {\n\t\tctype = ctype.Elem()\n\t}\n\tif reflect.Int64 == ctype.Kind() {\n\t\tif ival, err := num.Int64(); err == nil {\n\t\t\treturn ival, nil\n\t\t}\n\t\treturn nil, fmt.Errorf(\"invalid number for int64: %s\", num)\n\t}\n\tif reflect.Float64 == ctype.Kind() {\n\t\tif fval, err := num.Float64(); err == nil {\n\t\t\treturn fval, nil\n\t\t}\n\t\treturn nil, fmt.Errorf(\"invalid number for float64: %s\", num)\n\t}\n\tif reflect.String == ctype.Kind() {\n\t\treturn num.String(), nil\n\t}\n\treturn nil, fmt.Errorf(\"cannot convert number to %s\", ctype)\n}\n\nfunc SetBaseConfigValue(toMerge waveobj.MetaMapType) error {\n\tm, cerrs := ReadWaveHomeConfigFile(SettingsFile)\n\tif len(cerrs) > 0 {\n\t\treturn fmt.Errorf(\"error reading config file: %v\", cerrs[0])\n\t}\n\tif m == nil {\n\t\tm = make(waveobj.MetaMapType)\n\t}\n\tfor configKey, val := range toMerge {\n\t\tctype := getConfigKeyType(configKey)\n\t\tif ctype == nil {","sourceCodeStart":819,"sourceCodeEnd":855,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wconfig/settingsconfig.go#L819-L855","documentation":"convertJsonNumber fails when the target config field is float64 but num.Float64() errors — the JSON number is malformed or out of float64 range. The offending number string is included in the message.","triggerScenarios":"SetBaseConfigValue passing a json.Number for a config key typed float64 where the number cannot parse as float64 (extremely long digits, invalid literal that survived as json.Number).","commonSituations":"Programmatic config manipulation inserting malformed numeric strings; numbers exceeding IEEE-754 range like 1e400; corrupted config files with concatenated digits.","solutions":["Replace the value with a valid finite number in the config","Pass a native float64 instead of json.Number when calling SetBaseConfigValue","Validate the number with strconv.ParseFloat before submitting it"],"exampleFix":"// before\nval := json.Number(\"1e400\") // out of float64 range\n// after\nval := json.Number(\"1e38\")","handlingStrategy":"validation","validationCode":"f, err := strconv.ParseFloat(num.String(), 64)\nif err != nil || math.IsInf(f, 0) {\n    return fmt.Errorf(\"value %q is not a valid float64\", num.String())\n}","typeGuard":null,"tryCatchPattern":"if err := wconfig.SetBaseConfigValue(m); err != nil {\n    if strings.Contains(err.Error(), \"invalid number for float64\") {\n        return fmt.Errorf(\"supply a finite float value: %w\", err)\n    }\n    return err\n}","preventionTips":["Keep numeric values within IEEE-754 float64 range","Never inject raw digit strings into config programmatically","Validate numbers with strconv.ParseFloat before writing"],"tags":["config","json-number","float64","type-conversion","go"],"backgroundTag":"numeric-type-conversion-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}