{"record":{"id":"5fc40d82530f3ca6","repo":"larksuite/cli","slug":"s-must-contain-at-most-d-items","errorCode":null,"errorMessage":"%s must contain at most %d items","messagePattern":"(.+?) must contain at most (.+?) items","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_binder.go","lineNumber":477,"sourceCode":"\t\t\treturn fmt.Errorf(\"%s has an unsupported number value\", path)\n\t\t}\n\t\tif constraint.Minimum != nil && number < *constraint.Minimum {\n\t\t\treturn fmt.Errorf(\"%s must be at least %v\", path, *constraint.Minimum)\n\t\t}\n\t\tif constraint.Maximum != nil && number > *constraint.Maximum {\n\t\t\treturn fmt.Errorf(\"%s must be at most %v\", path, *constraint.Maximum)\n\t\t}\n\t\treturn nil\n\tcase typedArrayShape:\n\t\titems, ok := value.([]any)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"%s must be an array\", path)\n\t\t}\n\t\tif constraint.MinItems != nil && len(items) < *constraint.MinItems {\n\t\t\treturn fmt.Errorf(\"%s must contain at least %d items\", path, *constraint.MinItems)\n\t\t}\n\t\tif constraint.MaxItems != nil && len(items) > *constraint.MaxItems {\n\t\t\treturn fmt.Errorf(\"%s must contain at most %d items\", path, *constraint.MaxItems)\n\t\t}\n\t\tfor i, item := range items {\n\t\t\tif err := validateJSONValueAgainstShape(item, constraint.Items, fmt.Sprintf(\"%s[%d]\", path, i)); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\treturn nil\n\tcase typedObjectShape:\n\t\tobject, ok := value.(map[string]any)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"%s must be an object\", path)\n\t\t}\n\t\tfields := make(map[string]typedValueField, len(constraint.Fields))\n\t\tfor _, field := range constraint.Fields {\n\t\t\tfields[field.Name] = field\n\t\t\tif field.Required {\n\t\t\t\tif _, exists := object[field.Name]; !exists {\n\t\t\t\t\treturn fmt.Errorf(\"%s.%s is required\", path, field.Name)","sourceCodeStart":459,"sourceCodeEnd":495,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_binder.go#L459-L495","documentation":"Typed array shape validation: the supplied array has more items than the declared maxItems constraint.","triggerScenarios":"Passing an array longer than MaxItems — commonly batching more than the declared cap of IDs into a single batch call, e.g. --user-ids with 100 entries where at most 50 are allowed.","commonSituations":"Bulk operations that concatenate all target IDs without chunking; upstream API batch-size limits; script changes that increased input volume.","solutions":["Chunk the array into batches at or under the declared maximum and call the command once per batch.","Cap or truncate the list before invocation.","Check --help/schema for the exact MaxItems for this field.","If batches must be sequential, add pagination logic in the calling script."],"exampleFix":"// before\nlark-cli shortcut demo --user-ids '[100 ids...]'\n// error: user_ids must contain at most 50 items\n\n// after\n# chunk into groups of 50 and run per chunk\nlark-cli shortcut demo --user-ids '[id1,...,id50]'\nlark-cli shortcut demo --user-ids '[id51,...,id100]'","handlingStrategy":"validation","validationCode":"const maxItems = 50\nfor i := 0; i < len(ids); i += maxItems {\n    end := i + maxItems\n    if end > len(ids) { end = len(ids) }\n    chunk := ids[i:end]\n    // invoke the command with chunk\n}","typeGuard":"func hasMaxItems[T any](xs []T, n int) bool { return len(xs) <= n }","tryCatchPattern":"err := cmd.Run()\nif err != nil && strings.Contains(err.Error(), \"must contain at most\") {\n    // split the array into smaller batches and retry each batch\n}","preventionTips":["Chunk bulk ID lists to the documented MaxItems before calling.","Look up the batch cap in --help/schema.","Never assume a batch limit; verify per command.","Test bulk scripts with an over-cap list."],"tags":["validation","cli","array","batching"],"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"}