Commit fa8f4fc
authored
fix: handle nil options in TFunctionLoadArgs (#936)
## Summary
- Fix potential panic in `TFunctionLoadArgs` when `nil` options are
passed
- Add nil check that delegates to `TFunctionLoad` when options is nil
- Add test case for nil options scenario
## Motivation
There was a `FIXME` comment indicating that nil options check was
needed:
```go
// FIXME: should check nil of options
func (c *Compat) TFunctionLoadArgs(ctx context.Context, lib string, options *TFunctionLoadOptions) *StatusCmd {
// ...
if options.Replace { // <- panic if options is nil
When nil is passed as options, accessing options.Replace causes a panic.
```
## Changes
This PR follows the same pattern used in other functions like
HGetEXWithArgs and HSetEXWithArgs:
```
func (c *Compat) TFunctionLoadArgs(ctx context.Context, lib string, options *TFunctionLoadOptions) *StatusCmd {
if options == nil {
return c.TFunctionLoad(ctx, lib)
}
// ...
}
```1 parent 19aaff8 commit fa8f4fc
2 files changed
+8
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3483 | 3483 | | |
3484 | 3484 | | |
3485 | 3485 | | |
3486 | | - | |
3487 | 3486 | | |
| 3487 | + | |
| 3488 | + | |
| 3489 | + | |
3488 | 3490 | | |
3489 | 3491 | | |
3490 | 3492 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9498 | 9498 | | |
9499 | 9499 | | |
9500 | 9500 | | |
| 9501 | + | |
9501 | 9502 | | |
9502 | 9503 | | |
9503 | 9504 | | |
| |||
9513 | 9514 | | |
9514 | 9515 | | |
9515 | 9516 | | |
| 9517 | + | |
| 9518 | + | |
| 9519 | + | |
| 9520 | + | |
9516 | 9521 | | |
9517 | 9522 | | |
9518 | 9523 | | |
| |||
0 commit comments