larksuite/cli · error
%s must contain at least %d characters
Error message
%s must contain at least %d characters
What it means
A string-shape field with a MinLength constraint received a string shorter (in runes) than the declared minimum; validation fails with the required count in the message. Thrown by validateJSONValueAgainstShape in the typedStringShape branch after the type check.
Source
Thrown at shortcuts/common/typed_binder.go:420
if err != nil {
return fmt.Errorf("%s has invalid const: %w", path, err)
}
expected, err := decodeJSONValidationValue(expectedJSON)
if err != nil {
return fmt.Errorf("%s has invalid const: %w", path, err)
}
if !reflect.DeepEqual(value, expected) {
return fmt.Errorf("%s must equal %v", path, constraint.Value)
}
return nil
case typedStringShape:
text, ok := value.(string)
if !ok {
return fmt.Errorf("%s must be a string", path)
}
length := len([]rune(text))
if constraint.MinLength != nil && length < *constraint.MinLength {
return fmt.Errorf("%s must contain at least %d characters", path, *constraint.MinLength)
}
if constraint.MaxLength != nil && length > *constraint.MaxLength {
return fmt.Errorf("%s must contain at most %d characters", path, *constraint.MaxLength)
}
if len(constraint.Enum) > 0 && !slices.Contains(constraint.Enum, text) {
return fmt.Errorf("%s must be one of: %s", path, strings.Join(constraint.Enum, ", "))
}
return nil
case typedBooleanShape:
boolean, ok := value.(bool)
if !ok {
return fmt.Errorf("%s must be a boolean", path)
}
if len(constraint.Enum) > 0 && !slices.Contains(constraint.Enum, boolean) {
return fmt.Errorf("%s has an unsupported boolean value", path)
}
return nil
case typedIntegerShape:View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Supply a string at least as long as the declared minimum shown in the error.
- Omit the field if it is optional and you have no value.
- Check the config/env source — an unset variable often yields an empty string default.
- If the schema's minimum is wrong, update the MinLength constraint.
Example fix
// before
name := os.Getenv("DOC_NAME") // "" when unset
params.Set("name", name) // min 1
// after
name := os.Getenv("DOC_NAME")
if name == "" { return errors.New("DOC_NAME is required") }
params.Set("name", name) Defensive patterns
Strategy: validation
Validate before calling
if utf8.RuneCountInString(s) < minLen { return fmt.Errorf("needs at least %d characters", minLen) } Type guard
func meetsMinLength(s string, min int) bool { return utf8.RuneCountInString(s) >= min } Try / catch
if err := binder.Set("name", s); err != nil {
re := regexp.MustCompile(`must contain at least (\d+)`)
if m := re.FindStringSubmatch(err.Error()); m != nil {
return fmt.Errorf("name needs at least %s characters (got %d)", m[1], utf8.RuneCountInString(s))
}
return err
} Prevention
- Fail fast on empty env/config strings before binding.
- Remember length counts runes, not bytes, when validating multibyte text.
- Never use placeholder characters to satisfy required fields.
When it happens
Trigger: Passing an empty or too-short string to a constrained field — e.g. name: "" where min is 1, or a 3-char token where min is 8. Length is measured in runes, so multibyte characters count individually.
Common situations: Empty-string defaults from unset config variables; truncated user input; developers sending "-" or " " placeholders to satisfy required fields when MinLength > 1.
Related errors
- %s does not match any allowed shape
- %s must be null
- %s has invalid const: %w
- %s must equal %v
- %s must be a string
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/dcdf8453c2512035.
Report an issue: GitHub.