{"record":{"id":"43b47259df3e2dec","repo":"larksuite/cli","slug":"s-item-lengths-must-be-nonnegative","errorCode":null,"errorMessage":"%s item lengths must be nonnegative","messagePattern":"(.+?) item lengths must be nonnegative","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_data.go","lineNumber":293,"sourceCode":"\t\tfor _, number := range append(append([]float64{}, value.Enum...), pointerFloats(value.Minimum, value.Maximum)...) {\n\t\t\tif math.IsNaN(number) || math.IsInf(number, 0) {\n\t\t\t\treturn fmt.Errorf(\"%s number constraints must be finite\", path)\n\t\t\t}\n\t\t}\n\t\tif value.Minimum != nil && value.Maximum != nil && *value.Minimum > *value.Maximum {\n\t\t\treturn fmt.Errorf(\"%s minimum exceeds maximum\", path)\n\t\t}\n\tcase typedNullShape:\n\tcase typedConstShape:\n\t\tif _, err := json.Marshal(value.Value); err != nil {\n\t\t\treturn fmt.Errorf(\"%s const is not JSON-encodable: %w\", path, err)\n\t\t}\n\tcase typedArrayShape:\n\t\tif value.Items == nil {\n\t\t\treturn fmt.Errorf(\"%s.Items is required\", path)\n\t\t}\n\t\tif value.MinItems != nil && *value.MinItems < 0 || value.MaxItems != nil && *value.MaxItems < 0 {\n\t\t\treturn fmt.Errorf(\"%s item lengths must be nonnegative\", path)\n\t\t}\n\t\tif value.MinItems != nil && value.MaxItems != nil && *value.MinItems > *value.MaxItems {\n\t\t\treturn fmt.Errorf(\"%s minItems exceeds maxItems\", path)\n\t\t}\n\t\treturn validateShape(value.Items, path+\".Items\")\n\tcase typedObjectShape:\n\t\tseen := make(map[string]struct{})\n\t\tfor i := range value.Fields {\n\t\t\tfield := &value.Fields[i]\n\t\t\tif field.Name == \"\" {\n\t\t\t\treturn fmt.Errorf(\"%s.Fields[%d].Name is required\", path, i)\n\t\t\t}\n\t\t\tif _, duplicate := seen[field.Name]; duplicate {\n\t\t\t\treturn fmt.Errorf(\"%s contains duplicate field %q\", path, field.Name)\n\t\t\t}\n\t\t\tseen[field.Name] = struct{}{}\n\t\t\tif strings.TrimSpace(field.Description) == \"\" {\n\t\t\t\treturn fmt.Errorf(\"%s field %q Description is required\", path, field.Name)","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_data.go#L275-L311","documentation":"Shape validation guard: a typed array shape declares a negative minItems or maxItems. Item-count bounds must be nonnegative.","triggerScenarios":"An explicit Output.Data.Shape or DataField.Shape override declares typedArrayShape with a negative MinItems/MaxItems; or schema tag values lowered into the shape (minItems/maxItems) are negative.","commonSituations":"Typo'd negative constants in shape literals or tags; computed bounds from a length差 or config default that underflows; copy-paste sign errors when duplicating a constraint.","solutions":["Locate the array shape at the reported path and inspect MinItems/MaxItems.","Set the negative bound to a nonnegative integer or remove the pointer to drop the constraint.","Clamp computed values with max(0, n) before assignment.","Add a compile-path test asserting the bounds."],"exampleFix":"// before\ntypedArrayShape{Items: typedStringShape{}, MinItems: intPtr(-3)}\n// after\ntypedArrayShape{Items: typedStringShape{}, MinItems: intPtr(0)}","handlingStrategy":"validation","validationCode":"func validItemCountBounds(s typedArrayShape) bool {\n    nonneg := func(p *int) bool { return p == nil || *p >= 0 }\n    return nonneg(s.MinItems) && nonneg(s.MaxItems)\n}\n// if !validItemCountBounds(shape) { return errors.New(\"negative item-count bound\") }","typeGuard":"func hasNegativeItemCount(p *int) bool { return p != nil && *p < 0 }","tryCatchPattern":null,"preventionTips":["Use nil pointers, not negative values, for 'no item-count limit'.","Clamp derived counts with max(0, n) before assignment.","Author minItems/maxItems together and add compile-path tests."],"tags":["go","schema","validation","array-shape"],"backgroundTag":"invalid-schema-constraint","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"}