Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f2a4d10

Browse files
committed
allow NaN previous values to prevent any regressions
1 parent 6f94a4b commit f2a4d10

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

provider/parameter.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,13 @@ func (v *Validation) Valid(typ OptionType, value string, previous *string) error
653653
if previous != nil { // Only check if previous value exists
654654
previousNum, err := strconv.Atoi(*previous)
655655
if err != nil {
656-
return fmt.Errorf("previous value %q is not a number", *previous)
656+
// Do not throw an error for the previous value not being a number. Throwing an
657+
// error here would cause an unrepairable state for the user. This is
658+
// unfortunate, but there is not much we can do at this point.
659+
// TODO: Maybe we should enforce this, and have the calling coderd
660+
// do something to resolve it. Such as doing this check before calling
661+
// terraform apply.
662+
break
657663
}
658664

659665
if v.Monotonic == ValidationMonotonicIncreasing && !(num >= previousNum) {

provider/testdata/parameter_table.md

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
| NumDefDecBad | number | 4 | | 5 | | decreasing | | | | lower |
2929
| NumDefDecEq | number | 5 | | 5 | | decreasing | | 5 | true | |
3030
| NumDefIncEq | number | 5 | | 5 | | increasing | | 5 | true | |
31+
| NumDefIncNaN | number | a | | 5 | | increasing | | 5 | true | |
32+
| NumDefDecNaN | number | b | | 5 | | decreasing | | 5 | true | |
3133
| | | | | | | | | | | |
3234
| StrDef | string | | | hello | | | | hello | true | |
3335
| StrMonotonicity | string | | | hello | | increasing | | | | monotonic |

0 commit comments

Comments
 (0)