{"record":{"id":"070fe4cf714ac7ba","repo":"larksuite/cli","slug":"s-must-contain-at-most-d-characters","errorCode":null,"errorMessage":"%s must contain at most %d characters","messagePattern":"(.+?) must contain at most (.+?) characters","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_binder.go","lineNumber":423,"sourceCode":"\t\texpected, err := decodeJSONValidationValue(expectedJSON)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"%s has invalid const: %w\", path, err)\n\t\t}\n\t\tif !reflect.DeepEqual(value, expected) {\n\t\t\treturn fmt.Errorf(\"%s must equal %v\", path, constraint.Value)\n\t\t}\n\t\treturn nil\n\tcase typedStringShape:\n\t\ttext, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"%s must be a string\", path)\n\t\t}\n\t\tlength := len([]rune(text))\n\t\tif constraint.MinLength != nil && length < *constraint.MinLength {\n\t\t\treturn fmt.Errorf(\"%s must contain at least %d characters\", path, *constraint.MinLength)\n\t\t}\n\t\tif constraint.MaxLength != nil && length > *constraint.MaxLength {\n\t\t\treturn fmt.Errorf(\"%s must contain at most %d characters\", path, *constraint.MaxLength)\n\t\t}\n\t\tif len(constraint.Enum) > 0 && !slices.Contains(constraint.Enum, text) {\n\t\t\treturn fmt.Errorf(\"%s must be one of: %s\", path, strings.Join(constraint.Enum, \", \"))\n\t\t}\n\t\treturn nil\n\tcase typedBooleanShape:\n\t\tboolean, ok := value.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"%s must be a boolean\", path)\n\t\t}\n\t\tif len(constraint.Enum) > 0 && !slices.Contains(constraint.Enum, boolean) {\n\t\t\treturn fmt.Errorf(\"%s has an unsupported boolean value\", path)\n\t\t}\n\t\treturn nil\n\tcase typedIntegerShape:\n\t\tnumber, ok := validationInteger(value)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"%s must be an integer\", path)","sourceCodeStart":405,"sourceCodeEnd":441,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_binder.go#L405-L441","documentation":"This error comes from the typed binder's JSON shape validation: a string field value exceeded the maxLength constraint declared by the field's schema. The binder walks the value against the compiled shape (validateJSONValueAgainstShape) and rejects the input before any API call is made. Length is measured in runes, not bytes, so multibyte characters count once each.","triggerScenarios":"Calling a typed shortcut with a string argument/flag whose rune length exceeds the schema's maxLength (e.g. a 300-char value where the field allows 255); supplying an over-long string inside a nested object or array item validated by valueCompatibleWithShape.","commonSituations":"Pasting long descriptions, names, IDs or tokens into fields with fixed limits; generating test data that exceeds the documented limit; locale/emoji content inflating perceived-but-not-rune length; API limits tightened after a schema refresh.","solutions":["Shorten the string value to at or below the maxLength reported in the error message","Check the field's schema via the command's `schema` output to confirm the exact limit","If the value is generated programmatically, truncate to the limit (rune-aware, not byte-aware)","If the limit appears wrong, verify you are on an up-to-date catalog (re-run the meta fetch / update the CLI)"],"exampleFix":"// before\nname := strings.Repeat(\"a\", 300)\ncall(field(name))\n// after\nif len([]rune(name)) > 255 {\n    name = string([]rune(name)[:255])\n}\ncall(field(name))","handlingStrategy":"validation","validationCode":"func ensureMaxRunes(s string, max int) error {\n    if len([]rune(s)) > max {\n        return fmt.Errorf(\"value too long: %d > %d\", len([]rune(s)), max)\n    }\n    return nil\n}","typeGuard":"func isStringWithinLength(v any, max int) bool {\n    s, ok := v.(string)\n    return ok && len([]rune(s)) <= max\n}","tryCatchPattern":"err := bind(field, value)\nvar verr *FieldValidationError\nif errors.As(err, &verr) {\n    fmt.Fprintf(os.Stderr, \"fix input for %s: %v\\n\", verr.Field, err)\n    os.Exit(2)\n}","preventionTips":["Truncate user text to the schema limit before binding, using rune-aware slicing","Check `schema` output for maxLength when constructing requests dynamically","Add a unit test asserting generated fixtures respect maxLength","Never assume byte length equals character length for non-ASCII content"],"tags":["validation","cli","schema","string-length"],"backgroundTag":"schema-validation-failed","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}