kubernetes/kops · error

cannot interpret %q value as int64

Error message

cannot interpret %q value as int64

What it means

The target field is int64; strconv.ParseInt(s,10,64) failed, meaning the value is not a valid base-10 integer or overflows int64 (about ±9.2e18).

Source

Thrown at util/pkg/reflectutils/access.go:225

			newV = reflect.ValueOf(v)
		case "int16":
			v, err := strconv.ParseInt(newValue, 10, 16)
			if err != nil {
				return fmt.Errorf("cannot interpret %q value as int16", newValue)
			}
			v16 := int16(v)
			newV = reflect.ValueOf(v16)
		case "int32":
			v, err := strconv.ParseInt(newValue, 10, 32)
			if err != nil {
				return fmt.Errorf("cannot interpret %q value as int32", newValue)
			}
			v32 := int32(v)
			newV = reflect.ValueOf(v32)
		case "int64":
			v, err := strconv.ParseInt(newValue, 10, 64)
			if err != nil {
				return fmt.Errorf("cannot interpret %q value as int64", newValue)
			}
			v64 := int64(v)
			newV = reflect.ValueOf(v64)
		default:
			panic("missing case in int switch")
		}

	case "uint64", "uint32", "uint16", "uint":
		v, err := strconv.Atoi(newValue)
		if err != nil {
			return fmt.Errorf("cannot interpret %q value as unsigned integer", newValue)
		}

		switch t {
		case "uint":
			newV = reflect.ValueOf(v)
		case "uint16":
			v16 := uint16(v)

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Supply a plain decimal integer that fits int64.
  2. Unquote/expand scientific notation (1e19 -> 10000000000000000000 is still too big; use a smaller value).
  3. Check shell variables are non-empty before interpolating into the path value.
  4. Pre-validate with strconv.ParseInt(v,10,64).

Example fix

// before
SetString(&c, "spec.someInt64Field", "$SIZE") // SIZE empty -> ""
// after
if SIZE == ""; then SIZE="0"; fi
SetString(&c, "spec.someInt64Field", "$SIZE")
Defensive patterns

Strategy: validation

Validate before calling

if _, err := strconv.ParseInt(val, 10, 64); err != nil {
    return fmt.Errorf("value %q is not a valid int64", val)
}

Type guard

func isInt64(s string) bool {
    _, err := strconv.ParseInt(s, 10, 64)
    return err == nil
}

Try / catch

if err := SetString(&obj, path, val); err != nil {
    if strings.Contains(err.Error(), "as int64") {
        return fmt.Errorf("%q must be a decimal integer fitting int64", val)
    }
    return err
}

Prevention

When it happens

Trigger: SetString on an int64 field with "1e19", "18446744073709551616", "", or a non-numeric string.

Common situations: Timestamps or byte counts exceeding int64; scientific notation from other tooling; empty string from an unset shell variable.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/9e6fa51cdc45c02a. Report an issue: GitHub.