larksuite/cli · error

%s has an unsupported number value

Error message

%s has an unsupported number value

What it means

The value is a valid number but not among the discrete values permitted by the schema's number enum. Like the integer/boolean enum errors, this is a value-set rejection raised by validateJSONValueAgainstShape after the type check passes.

Source

Thrown at shortcuts/common/typed_binder.go:459

			return fmt.Errorf("%s must be an integer", path)
		}
		if constraint.Minimum != nil && number < *constraint.Minimum {
			return fmt.Errorf("%s must be at least %d", path, *constraint.Minimum)
		}
		if constraint.Maximum != nil && number > *constraint.Maximum {
			return fmt.Errorf("%s must be at most %d", path, *constraint.Maximum)
		}
		if len(constraint.Enum) > 0 && !slices.Contains(constraint.Enum, number) {
			return fmt.Errorf("%s has an unsupported integer value", path)
		}
		return nil
	case typedNumberShape:
		number, ok := validationNumber(value)
		if !ok {
			return fmt.Errorf("%s must be a number", path)
		}
		if len(constraint.Enum) > 0 && !slices.Contains(constraint.Enum, number) {
			return fmt.Errorf("%s has an unsupported number value", path)
		}
		if constraint.Minimum != nil && number < *constraint.Minimum {
			return fmt.Errorf("%s must be at least %v", path, *constraint.Minimum)
		}
		if constraint.Maximum != nil && number > *constraint.Maximum {
			return fmt.Errorf("%s must be at most %v", path, *constraint.Maximum)
		}
		return nil
	case typedArrayShape:
		items, ok := value.([]any)
		if !ok {
			return fmt.Errorf("%s must be an array", path)
		}
		if constraint.MinItems != nil && len(items) < *constraint.MinItems {
			return fmt.Errorf("%s must contain at least %d items", path, *constraint.MinItems)
		}
		if constraint.MaxItems != nil && len(items) > *constraint.MaxItems {
			return fmt.Errorf("%s must contain at most %d items", path, *constraint.MaxItems)

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Use one of the accepted values listed for the field (check `schema` output)
  2. Snap the input to the nearest allowed enum value before the call
  3. If a previously valid value now fails, refresh the CLI catalog metadata
  4. Avoid computing the value at runtime unless the result is guaranteed to be in the enum

Example fix

// before
discount := 0.15
// after
discount = 0.25 // must be one of the schema's enum values (e.g. 0.25, 0.5, 1.0)
Defensive patterns

Strategy: validation

Validate before calling

func ensureFloatEnum(v float64, allowed []float64) error {
    for _, a := range allowed {
        if v == a {
            return nil
        }
    }
    return fmt.Errorf("%v not in allowed set %v", v, allowed)
}

Type guard

func isAllowedNumber(v any, allowed ...float64) bool {
    n, ok := v.(float64)
    if !ok {
        return false
    }
    for _, a := range allowed {
        if n == a {
            return true
        }
    }
    return false
}

Try / catch

if err := bind(field, v); err != nil {
    if strings.Contains(err.Error(), "unsupported number value") {
        return fmt.Errorf("field %s accepts only fixed values; pick from `lark ... schema`: %w", field, err)
    }
    return err
}

Prevention

When it happens

Trigger: Supplying 0.5 to a field whose enum is [0.25, 1.0, 2.0]; passing an arbitrary rate/multiplier where only fixed step values are accepted; float representation edge values differing from the declared enum after JSON decode.

Common situations: Choosing in-between values for rate/step-like fields; converting percentages (33.3) where the API accepts fixed fractions; API updates changing the accepted set.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04). Data as JSON: /api/errors/e09b28363790284f. Report an issue: GitHub.