{"record":{"id":"51fb470cf6ba2ce1","repo":"larksuite/cli","slug":"sarray-has-d-items-maximum-is-d","errorCode":null,"errorMessage":"%sarray has %d items, maximum is %d","messagePattern":"(.+?)array has (.+?) items, maximum is (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/sheets/flag_schema_validate.go","lineNumber":388,"sourceCode":"\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 != \"\" {\n\t\t\t\tmsg += fmt.Sprintf(` (did you mean %q?)`, hint)\n\t\t\t}\n\t\t\tc.add(fmt.Errorf(\"%s\", msg)) //nolint:forbidigo // intermediate error; validateFlagAgainstSchema wraps it into a typed flag validation error with a --print-schema hint","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/sheets/flag_schema_validate.go#L370-L406","documentation":"Schema validation error from collectSchemaErrors: an array flag value has more items than the schema's `maxItems`. The intermediate error is wrapped by validateFlagAgainstSchema into a typed flag validation error with a --print-schema hint.","triggerScenarios":"Passing a JSON array flag exceeding `maxItems`, e.g. a batch update capped at 100 rows receiving 500.","commonSituations":"Batching large exports in one call; API version changes lowering the allowed batch size; concatenating multiple datasets without splitting.","solutions":["Trim or split the array so it has at most the schema's maximum items.","Chunk the work into multiple invocations, each within maxItems.","Check the bound via --print-schema and enforce it in your batch builder."],"exampleFix":"// before\n--rows '[...500 items...]'  // maxItems is 100\n// after\n// chunk into 5 calls of --rows '[...100 items...]'","handlingStrategy":"validation","validationCode":"const maxItems = 100; // from schema\nif (Array.isArray(arr) && arr.length > maxItems) {\n  throw new Error(`array exceeds ${maxItems} items: ${arr.length}`);\n}","typeGuard":"function hasAtMostItems(v: unknown, max: number): v is unknown[] {\n  return Array.isArray(v) && v.length <= max;\n}","tryCatchPattern":null,"preventionTips":["Chunk large datasets into batches of maxItems before invoking.","Compute batch size from the schema bound, not a hardcoded guess.","Re-check bounds when upgrading CLI or API versions."],"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"}