Skip to content

Commit e756608

Browse files
committed
fix error check and context setting
1 parent 59eefa3 commit e756608

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
- Optimize `has_value` function logic.
55
- Modify missing key for `key(s)_delete` function from error to warning.
66
- Protect against overflows in `combinations` and `factorial` functions.
7+
- Fix input parameter reflection error check in `sqrt` function.
8+
- Improve error messages for invalid input parameters in `combinations` function.
9+
- Validate divisor is not 0 in `mod` function.
710

811
### 2.2.0
912
- Rename former `sort_list` to `sort_list_string`.

stdlib/number/sqrt.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ func (*sqrtFunction) Run(ctx context.Context, req function.RunRequest, resp *fun
4444
var inputNum float64
4545

4646
resp.Error = req.Arguments.Get(ctx, &inputNum)
47+
if resp.Error != nil {
48+
return
49+
}
50+
51+
ctx = tflog.SetField(ctx, "sqrt: number", inputNum)
4752

4853
// validate input parameters
4954
if inputNum < 0 {
@@ -57,8 +62,6 @@ func (*sqrtFunction) Run(ctx context.Context, req function.RunRequest, resp *fun
5762
return
5863
}
5964

60-
ctx = tflog.SetField(ctx, "sqrt: number", inputNum)
61-
6265
// determine the square root
6366
sqrt := math.Sqrt(inputNum)
6467
ctx = tflog.SetField(ctx, "sqrt: square root", sqrt)

0 commit comments

Comments
 (0)