{"record":{"id":"21a8747f2b8625c4","repo":"larksuite/cli","slug":"s-minlength-exceeds-maxlength","errorCode":null,"errorMessage":"%s minLength exceeds maxLength","messagePattern":"(.+?) minLength exceeds maxLength","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_data.go","lineNumber":267,"sourceCode":"\t\t\treturn typedObjectShape{}, fmt.Errorf(\"%s field %s (%s): %w\", path, field.Name, name, err)\n\t\t}\n\t\tshape.Fields = append(shape.Fields, typedValueField{Name: name, Description: description, Required: schema.required, Shape: fieldShape})\n\t}\n\treturn shape, nil\n}\n\nfunc validateShape(shape typedValueShape, path string) error {\n\tif shape == nil {\n\t\treturn fmt.Errorf(\"%s is nil\", path)\n\t}\n\tswitch value := shape.(type) {\n\tcase anyJSONShape:\n\tcase typedStringShape:\n\t\tif value.MinLength != nil && *value.MinLength < 0 || value.MaxLength != nil && *value.MaxLength < 0 {\n\t\t\treturn fmt.Errorf(\"%s string lengths must be nonnegative\", path)\n\t\t}\n\t\tif value.MinLength != nil && value.MaxLength != nil && *value.MinLength > *value.MaxLength {\n\t\t\treturn fmt.Errorf(\"%s minLength exceeds maxLength\", path)\n\t\t}\n\tcase typedBooleanShape:\n\tcase typedIntegerShape:\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 typedNumberShape:\n\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 {","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_data.go#L249-L285","documentation":"validateShape rejects a typedStringShape where both MinLength and MaxLength are set and MinLength is greater than MaxLength. Such a range admits no valid string, so the declaration is rejected at startup with the shape path included.","triggerScenarios":"An explicit Output.Data.Shape or DataField.Shape override declares a string shape with contradictory bounds, e.g. MinLength=10, MaxLength=5; or bounds swapped when programmatically deriving min/max from data.","commonSituations":"Swapping the two values by argument-order mistakes in a helper; refactoring that renames/reorders fields and shifts the bounds; tightening min without raising max.","solutions":["Compare MinLength and MaxLength at the reported path; ensure min <= max.","Swap the values if they were transposed, or raise MaxLength / lower MinLength.","Remove one bound if only a single-sided constraint is intended.","Add a unit test that builds the shape so contradictions fail in tests before startup."],"exampleFix":"// before\ntypedStringShape{MinLength: intPtr(10), MaxLength: intPtr(5)}\n// after\ntypedStringShape{MinLength: intPtr(5), MaxLength: intPtr(10)}","handlingStrategy":"validation","validationCode":"func validStringRange(s typedStringShape) bool {\n    return s.MinLength == nil || s.MaxLength == nil || *s.MinLength <= *s.MaxLength\n}\n// if !validStringRange(shape) { return errors.New(\"minLength exceeds maxLength\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Construct min/max bounds together in one helper with an ordering assertion.","Avoid editing one bound in isolation; search for the sibling bound when tightening ranges.","Add table tests covering the authored constraint pairs."],"tags":["go","schema","validation","string-constraints"],"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"}