{"record":{"id":"2589e098dd377a3a","repo":"wavetermdev/waveterm","slug":"cannot-convert-s-v","errorCode":null,"errorMessage":"cannot convert %s: %v","messagePattern":"cannot convert (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wconfig/settingsconfig.go","lineNumber":865,"sourceCode":"\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 {\n\t\t\treturn fmt.Errorf(\"invalid config key: %s\", configKey)\n\t\t}\n\t\tif val == nil {\n\t\t\tdelete(m, configKey)\n\t\t} else {\n\t\t\trtype := reflect.TypeOf(val)\n\t\t\tif rtype == reflect.TypeOf(dummyNumber) {\n\t\t\t\tconvertedVal, err := convertJsonNumber(val.(json.Number), ctype)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"cannot convert %s: %v\", configKey, err)\n\t\t\t\t}\n\t\t\t\tval = convertedVal\n\t\t\t\trtype = reflect.TypeOf(val)\n\t\t\t}\n\t\t\tif rtype != ctype {\n\t\t\t\tif ctype == reflect.PointerTo(rtype) {\n\t\t\t\t\tm[configKey] = &val\n\t\t\t\t} else {\n\t\t\t\t\treturn fmt.Errorf(\"invalid value type for %s: %T\", configKey, val)\n\t\t\t\t}\n\t\t\t}\n\t\t\tm[configKey] = val\n\t\t}\n\t}\n\treturn WriteWaveHomeConfigFile(SettingsFile, m)\n}\n\nfunc SetConnectionsConfigValue(connName string, toMerge waveobj.MetaMapType) error {","sourceCodeStart":847,"sourceCodeEnd":883,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wconfig/settingsconfig.go#L847-L883","documentation":"SetBaseConfigValue wraps a convertJsonNumber failure as 'cannot convert %s: %v' when the supplied value is a json.Number that cannot be converted to the key's declared type (int64, float64, or string). The key name and the inner conversion error are included.","triggerScenarios":"Passing json.Number values via SetBaseConfigValue where the number is fractional/out-of-range for an int64 key, invalid for a float64 key, or the key's type is not number-convertible at all.","commonSituations":"Round-tripping parsed JSON where numbers arrive as json.Number; supplying decimals to integer settings; supplying numbers to boolean/struct settings.","solutions":["Read the inner error: fix the number (make it integral, in range, or valid)","Prefer passing native Go types (int64, float64, string, bool) instead of json.Number","Confirm the key's declared type matches the value you are supplying"],"exampleFix":"// before\nwconfig.SetBaseConfigValue(waveobj.MetaMapType{\"term:fontsize\": json.Number(\"12.75\")})\n// after\nwconfig.SetBaseConfigValue(waveobj.MetaMapType{\"term:fontsize\": 13})","handlingStrategy":"validation","validationCode":"// decode numbers into concrete types before merging\nif raw, ok := val.(json.Number); ok {\n    if i, err := raw.Int64(); err == nil {\n        val = i\n    } else if f, err := raw.Float64(); err == nil {\n        val = f\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := wconfig.SetBaseConfigValue(m); err != nil {\n    if strings.Contains(err.Error(), \"cannot convert\") {\n        return fmt.Errorf(\"fix numeric value type before merge: %w\", err)\n    }\n    return err\n}","preventionTips":["Avoid passing json.Number into SetBaseConfigValue; convert first","Ensure integers are whole and in range for int64 keys","Verify each key's declared type before merging"],"tags":["config","type-conversion","json-number","settings","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"}