{"record":{"id":"dc40c847a41c54e0","repo":"larksuite/cli","slug":"s-must-contain-at-least-d-items","errorCode":null,"errorMessage":"%s must contain at least %d items","messagePattern":"(.+?) must contain at least (.+?) items","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_binder.go","lineNumber":474,"sourceCode":"\t\t\treturn fmt.Errorf(\"%s must be a number\", path)\n\t\t}\n\t\tif len(constraint.Enum) > 0 && !slices.Contains(constraint.Enum, number) {\n\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","sourceCodeStart":456,"sourceCodeEnd":492,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_binder.go#L456-L492","documentation":"Typed array shape validation: the supplied array has fewer items than the declared minItems constraint.","triggerScenarios":"Passing an empty array or an array with too few elements to a field whose shape declares MinItems — e.g. --user-ids '[]' where at least 1 user id is required.","commonSituations":"Automated pipelines submitting empty lists when the upstream collection is empty instead of skipping the call; copying examples trimmed down; loops that build arrays from zero results.","solutions":["Supply at least the required number of items in the array.","Guard the caller: skip the command or handle the empty case before invoking when the list may be empty.","Check --help/schema for the documented minimum length.","If the API genuinely allows empty lists, verify the shape constraint against upstream metadata."],"exampleFix":"// before\nlark-cli shortcut demo --user-ids '[]'\n// error: user_ids must contain at least 1 items\n\n// after\nlark-cli shortcut demo --user-ids '[\"ou_x\"]'","handlingStrategy":"validation","validationCode":"ids=$(jq -c '.user_ids // []' payload.json)\nlen=$(echo \"$ids\" | jq 'length')\nif [ \"$len\" -lt 1 ]; then\n  echo \"user_ids needs at least 1 item; skipping call\" >&2; exit 2\nfi","typeGuard":"func hasMinItems[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 least\") {\n    // handle the empty-collection case upstream instead of calling\n}","preventionTips":["Skip the command entirely when the source list is empty.","Validate array length with jq before invocation.","Check MinItems in the schema for the field.","Avoid building arrays from unguarded empty results."],"tags":["validation","cli","array"],"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"}