wavetermdev/waveterm · error

invalid number for int64: %s

Error message

invalid number for int64: %s

What it means

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.

Source

Thrown at pkg/wconfig/settingsconfig.go:831

		buf.WriteString("\n")
	}
	buf.WriteString("}")
	return buf.Bytes(), nil
}

var dummyNumber json.Number

func convertJsonNumber(num json.Number, ctype reflect.Type) (interface{}, error) {
	// ctype might be int64, float64, string, *int64, *float64, *string
	// switch on ctype first
	if ctype.Kind() == reflect.Pointer {
		ctype = ctype.Elem()
	}
	if reflect.Int64 == ctype.Kind() {
		if ival, err := num.Int64(); err == nil {
			return ival, nil
		}
		return nil, fmt.Errorf("invalid number for int64: %s", num)
	}
	if reflect.Float64 == ctype.Kind() {
		if fval, err := num.Float64(); err == nil {
			return fval, nil
		}
		return nil, fmt.Errorf("invalid number for float64: %s", num)
	}
	if reflect.String == ctype.Kind() {
		return num.String(), nil
	}
	return nil, fmt.Errorf("cannot convert number to %s", ctype)
}

func SetBaseConfigValue(toMerge waveobj.MetaMapType) error {
	m, cerrs := ReadWaveHomeConfigFile(SettingsFile)
	if len(cerrs) > 0 {
		return fmt.Errorf("error reading config file: %v", cerrs[0])
	}

View on GitHub (pinned to a4447c1563)

Solutions

  1. Change the value in the config to a whole number that fits in int64
  2. If the setting truly needs fractional values, verify the config key's declared type — it may be the wrong key
  3. Merge via SetBaseConfigValue with a Go int64 value instead of a raw json.Number

Example fix

// before
m.SetBaseConfigValue(waveobj.MetaMapType{"telemetry:limits:concurrencepct": json.Number("50.5")})
// after
m.SetBaseConfigValue(waveobj.MetaMapType{"telemetry:limits:concurrencepct": json.Number("50")})
Defensive patterns

Strategy: validation

Validate before calling

n, err := strconv.ParseInt(num.String(), 10, 64)
if err != nil {
    return fmt.Errorf("value %q is not a valid int64 for this key", num.String())
}

Try / catch

if err := wconfig.SetBaseConfigValue(m); err != nil {
    if strings.Contains(err.Error(), "invalid number for int64") {
        return fmt.Errorf("use a whole number for this setting: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: 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).

Common situations: Putting a decimal value into an integer config setting; pasting very large numbers from other tools; unit mistakes (milliseconds vs seconds producing huge values).

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/b3cd833f97226b5f. Report an issue: GitHub.