fix conversion for int/uint in ReplaceVariables#19
Merged
jaypipes merged 1 commit intogdt-dev:mainfrom Dec 30, 2025
Merged
Conversation
There was an unsafe type conversion in the type switch statement in
`cotnext.ReplaceVariables()` that caused a panic that looked like this:
```
panic: interface conversion: interface {} is int64, not int
goroutine 147 [running]:
github.com/gdt-dev/core/context.ReplaceVariables({0x105cbd6c8?, 0x140007a5030?}, {0x14000042480, 0xc})
/Users/abdul/go/pkg/mod/github.com/gdt-dev/core@v1.10.4/context/getter.go:132 +0x31c
github.com/gdt-dev/kube.(*Action).get(0x140000b2a20, {0x105cbd6c8, 0x140007a5030}, 0x14000483530, {0x1400027aab8, 0x5}, 0x14000053d00)
/Users/abdul/go/pkg/mod/github.com/gdt-dev/kube@v1.10.3/action.go:126 +0x60
github.com/gdt-dev/kube.(*Action).Do(0x105cbd6c8?, {0x105cbd6c8?, 0x140007a5030?}, 0x1400027aab8?, {0x1400027aab8?, 0x1046819ec?}, 0x14000567cc8?)
/Users/abdul/go/pkg/mod/github.com/gdt-dev/kube@v1.10.3/action.go:104 +0xb8
github.com/gdt-dev/kube.(*Spec).Eval(0x140000c2d80, {0x105cbd6c8, 0x140007a5030})
/Users/abdul/go/pkg/mod/github.com/gdt-dev/kube@v1.10.3/eval.go:37 +0x1e8
github.com/gdt-dev/core/scenario.(*Scenario).execSpec(0x0?, {0x105cbd6c8, 0x140007a5030}, 0x140007a4fc0, 0x140002406c0, 0x0?, {0x105cbf320, 0x140000c2d80})
/Users/abdul/go/pkg/mod/github.com/gdt-dev/core@v1.10.4/scenario/run.go:369 +0x3ac1
```
This patch fixes that unsafe type conversion and uses the recommended
`strconv.FormatInt` and `strconv.FormatUint` functions for safe
conversion of int64 and uint64 to string.
Issue gdt-dev/gdt#72
Signed-off-by: Jay Pipes <jaypipes@gmail.com>
d0669a1 to
12b5c75
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There was an unsafe type conversion in the type switch statement in
cotnext.ReplaceVariables()that caused a panic that looked like this:This patch fixes that unsafe type conversion and uses the recommended
strconv.FormatIntandstrconv.FormatUintfunctions for safe conversion of int64 and uint64 to string.Issue gdt-dev/gdt#72