{"record":{"id":"1c06a147d3c06487","repo":"larksuite/cli","slug":"sarray-has-d-items-minimum-is-d","errorCode":null,"errorMessage":"%sarray has %d items, minimum is %d","messagePattern":"(.+?)array has (.+?) items, minimum is (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/sheets/flag_schema_validate.go","lineNumber":385,"sourceCode":"\t\t\treturn // wrong container type — descending would cascade nonsense.\n\t\t}\n\t}\n\n\t// Numeric bounds — only checked when value is a number (type mismatch\n\t// already reported above). Apply to both `number` and `integer` types.\n\tif num, ok := value.(float64); ok {\n\t\tif schema.Minimum != nil && num < *schema.Minimum {\n\t\t\tc.add(fmt.Errorf(\"%svalue %v is below minimum %v\", pathPrefix(path), num, *schema.Minimum)) //nolint:forbidigo // intermediate error; validateFlagAgainstSchema wraps it into a typed flag validation error with a --print-schema hint\n\t\t}\n\t\tif schema.Maximum != nil && num > *schema.Maximum {\n\t\t\tc.add(fmt.Errorf(\"%svalue %v is above maximum %v\", pathPrefix(path), num, *schema.Maximum)) //nolint:forbidigo // intermediate error; validateFlagAgainstSchema wraps it into a typed flag validation error with a --print-schema hint\n\t\t}\n\t}\n\n\t// Array length bounds — only checked when value is an array.\n\tif arr, ok := value.([]interface{}); ok {\n\t\tif schema.MinItems != nil && len(arr) < *schema.MinItems {\n\t\t\tc.add(fmt.Errorf(\"%sarray has %d items, minimum is %d\", pathPrefix(path), len(arr), *schema.MinItems)) //nolint:forbidigo // intermediate error; validateFlagAgainstSchema wraps it into a typed flag validation error with a --print-schema hint\n\t\t}\n\t\tif schema.MaxItems != nil && len(arr) > *schema.MaxItems {\n\t\t\tc.add(fmt.Errorf(\"%sarray has %d items, maximum is %d\", pathPrefix(path), len(arr), *schema.MaxItems)) //nolint:forbidigo // intermediate error; validateFlagAgainstSchema wraps it into a typed flag validation error with a --print-schema hint\n\t\t}\n\t}\n\n\tif len(schema.Enum) > 0 {\n\t\tmatched := false\n\t\tfor _, allowed := range schema.Enum {\n\t\t\tif jsonEqual(allowed, value) {\n\t\t\t\tmatched = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !matched {\n\t\t\tmsg := fmt.Sprintf(\"%svalue %s is not in enum %s\",\n\t\t\t\tpathPrefix(path), formatJSONValue(value), formatEnum(schema.Enum))\n\t\t\tif hint := suggestEnumForError(value, schema.Enum); hint != \"\" {","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/sheets/flag_schema_validate.go#L367-L403","documentation":"Schema validation error from collectSchemaErrors: an array flag value has fewer items than the schema's `minItems`. The intermediate error is wrapped by validateFlagAgainstSchema into a typed flag validation error with a --print-schema hint.","triggerScenarios":"Passing a JSON array flag with fewer elements than `minItems`, e.g. a batch operation requiring at least 1 item receiving an empty array `[]`.","commonSituations":"Filtering an upstream list before batching and ending up with zero rows; constructing arrays dynamically and not checking emptiness; defaulting an optional array to [].","solutions":["Ensure the array contains at least the minimum number of items required by the schema.","Guard against empty lists: skip the call or error out upstream when the array is empty.","Inspect the schema bounds with --print-schema before building the payload."],"exampleFix":"// before\n--values '[]'  // minItems is 1\n// after\n--values '[{\"row\": 1}]'","handlingStrategy":"validation","validationCode":"const minItems = 1; // from schema\nif (Array.isArray(arr) && arr.length < minItems) {\n  throw new Error(`array needs at least ${minItems} item(s), got ${arr.length}`);\n}","typeGuard":"function hasMinItems(v: unknown, min: number): v is unknown[] {\n  return Array.isArray(v) && v.length >= min;\n}","tryCatchPattern":null,"preventionTips":["Skip the call entirely when a filtered list is empty instead of sending [].","Assert array length before building the payload.","Never default a minItems-bounded array to []."],"tags":["sheets","schema-validation","arrays"],"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"}