{"record":{"id":"582517234603ff3d","repo":"larksuite/cli","slug":"s-number-constraints-must-be-finite","errorCode":null,"errorMessage":"%s number constraints must be finite","messagePattern":"(.+?) number constraints must be finite","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_data.go","lineNumber":277,"sourceCode":"\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 {\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 {","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_data.go#L259-L295","documentation":"validateShape rejects a typedNumberShape whose Enum values, Minimum, or Maximum are NaN or +/-Inf. Floating-point specials cannot be represented in JSON schema constraints, so the declaration is refused at startup; the message includes the shape path.","triggerScenarios":"An explicit Output.Data.Shape or DataField.Shape override declares typedNumberShape with a NaN/Inf in Enum, Minimum, or Maximum; or parseFiniteFloatBits-adjacent code paths / programmatic computation inject math.Inf or math.NaN into the shape.","commonSituations":"Computing a bound via division by zero or a sentinel value like math.MaxFloat64 misuse; loading limits from config where a missing value decodes to Inf; accidentally using NaN as an 'unset' marker instead of nil.","solutions":["Inspect Enum, Minimum, and Maximum at the reported path; replace any NaN/Inf with finite values.","Use nil pointers instead of NaN/Inf to express 'no bound'.","Validate computed bounds with math.IsFinite before building the shape.","Fix the upstream source (config, constants) producing the special value."],"exampleFix":"// before\nlimit := math.MaxFloat64 * 2 // +Inf\nshape := typedNumberShape{Maximum: &limit}\n// after\nshape := typedNumberShape{} // no bound, or a finite maximum","handlingStrategy":"validation","validationCode":"func finiteFloat(p *float64) bool { return p == nil || !math.IsNaN(*p) && !math.IsInf(*p, 0) }\nfunc validNumberShape(s typedNumberShape) bool {\n    if !finiteFloat(s.Minimum) || !finiteFloat(s.Maximum) { return false }\n    for _, e := range s.Enum { if math.IsNaN(e) || math.IsInf(e, 0) { return false } }\n    return true\n}\n// if !validNumberShape(shape) { return errors.New(\"non-finite number constraint\") }","typeGuard":"func isFinite(f float64) bool { return !math.IsNaN(f) && !math.IsInf(f, 0) }","tryCatchPattern":null,"preventionTips":["Use nil pointers for 'no bound', never NaN or Inf sentinels.","Sanity-check bounds read from config or computed at runtime with isFinite.","Avoid arithmetic that can overflow to Inf (e.g. MaxFloat64 * 2) in constraint code."],"tags":["go","schema","validation","floating-point"],"backgroundTag":"non-finite-number-schema","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"}