{"record":{"id":"b3cd833f97226b5f","repo":"wavetermdev/waveterm","slug":"invalid-number-for-int64-s","errorCode":null,"errorMessage":"invalid number for int64: %s","messagePattern":"invalid number for int64: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wconfig/settingsconfig.go","lineNumber":831,"sourceCode":"\t\tbuf.WriteString(\"\\n\")\n\t}\n\tbuf.WriteString(\"}\")\n\treturn buf.Bytes(), nil\n}\n\nvar 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}","sourceCodeStart":813,"sourceCodeEnd":849,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wconfig/settingsconfig.go#L813-L849","documentation":"convertJsonNumber fails when a JSON number from config must land in an int64-typed config field but num.Int64() errors — i.e. the number is fractional, out of int64 range, or otherwise not representable as an integer. The numeric string is echoed in the message.","triggerScenarios":"SetBaseConfigValue receiving a json.Number value for a config key whose registered Go type is int64, where the number is fractional (e.g. 1.5) or exceeds int64 range (e.g. 1e30).","commonSituations":"Putting a decimal value into an integer config setting; pasting very large numbers from other tools; unit mistakes (milliseconds vs seconds producing huge values).","solutions":["Change the value in the config to a whole number that fits in int64","If the setting truly needs fractional values, verify the config key's declared type — it may be the wrong key","Merge via SetBaseConfigValue with a Go int64 value instead of a raw json.Number"],"exampleFix":"// before\nm.SetBaseConfigValue(waveobj.MetaMapType{\"telemetry:limits:concurrencepct\": json.Number(\"50.5\")})\n// after\nm.SetBaseConfigValue(waveobj.MetaMapType{\"telemetry:limits:concurrencepct\": json.Number(\"50\")})","handlingStrategy":"validation","validationCode":"n, err := strconv.ParseInt(num.String(), 10, 64)\nif err != nil {\n    return fmt.Errorf(\"value %q is not a valid int64 for this key\", num.String())\n}","typeGuard":null,"tryCatchPattern":"if err := wconfig.SetBaseConfigValue(m); err != nil {\n    if strings.Contains(err.Error(), \"invalid number for int64\") {\n        return fmt.Errorf(\"use a whole number for this setting: %w\", err)\n    }\n    return err\n}","preventionTips":["Use whole numbers for integer-typed config keys","Check key types via the generated settings meta constants before setting","Avoid json.Number; pass typed Go values directly"],"tags":["config","json-number","type-conversion","int64","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"}