{"record":{"id":"de8da6de8bc31a8a","repo":"wavetermdev/waveterm","slug":"invalid-value-type-for-s-t","errorCode":null,"errorMessage":"invalid value type for %s: %T","messagePattern":"invalid value type for (.+?): %T","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wconfig/settingsconfig.go","lineNumber":874,"sourceCode":"\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 {\n\tm, cerrs := ReadWaveHomeConfigFile(ConnectionsFile)\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\tconnData := m.GetMap(connName)\n\tif connData == nil {","sourceCodeStart":856,"sourceCodeEnd":892,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wconfig/settingsconfig.go#L856-L892","documentation":"SetBaseConfigValue compares reflect.TypeOf(val) against the key's registered type; if they differ and the declared type is not a pointer wrapper of the value's type, it returns 'invalid value type for %s: %T'. Only exact Go type matches (or pointer-wrappable) values are accepted.","triggerScenarios":"Calling SetBaseConfigValue with a value whose Go type does not match the key's declared type — e.g. float64 for an int64 key, string for a bool key, int (not int64) where int64 is declared.","commonSituations":"Using untyped Go literals (int) against int64-typed keys; sending strings for numeric keys; version drift where a key's type changed.","solutions":["Convert the value to the exact declared Go type before calling (e.g. int64(14), float64(0.5))","Look up the key's type via getConfigKeyType or the generated meta constants","Avoid raw json.Number; decode into the concrete type first"],"exampleFix":"// before\nwconfig.SetBaseConfigValue(waveobj.MetaMapType{\"term:fontsize\": 14}) // int, wants float64\n// after\nwconfig.SetBaseConfigValue(waveobj.MetaMapType{\"term:fontsize\": float64(14)})","handlingStrategy":"type-guard","validationCode":"// verify the value type matches the key's registered type\nctype := getConfigKeyType(key)\nif ctype != nil && reflect.TypeOf(val) != ctype && reflect.TypeOf(val) != ctype.Elem() {\n    return fmt.Errorf(\"key %s expects %s, got %T\", key, ctype, val)\n}","typeGuard":"func valueMatchesKeyType(key string, val any) bool {\n    ctype := getConfigKeyType(key)\n    if ctype == nil { return false }\n    rt := reflect.TypeOf(val)\n    return rt == ctype || rt == ctype.Elem() || ctype == reflect.PointerTo(rt)\n}","tryCatchPattern":"if err := wconfig.SetBaseConfigValue(m); err != nil {\n    if strings.Contains(err.Error(), \"invalid value type for\") {\n        return fmt.Errorf(\"convert value to the key's exact Go type: %w\", err)\n    }\n    return err\n}","preventionTips":["Always use explicit typed literals (int64(...), float64(...)) for config values","Look up the key's registered type before constructing the MetaMapType","Re-check types after upgrading Wave, since key types can change between versions"],"tags":["config","type-mismatch","validation","settings","go"],"backgroundTag":"config-value-type-mismatch","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}