Skip to content

Commit 94ac23f

Browse files
committed
Fix potential panics in object to string map conversions.
These panics were caused by invalid type assertions.
1 parent 6820759 commit 94ac23f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
- Support for Granular Security Lists in Load Balancer
99
- Support for Network Security Groups in databases
1010

11+
### Fixed
12+
- Address panics caused by invalid type assertions in object map conversion. This could potentially affect attributes
13+
that are maps of string values.
14+
1115
## 3.32.0 (July 03, 2019)
1216

1317
### Added

oci/helpers.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package provider
44

55
import (
66
"fmt"
7+
"log"
78
"math/rand"
89
"time"
910

@@ -61,7 +62,14 @@ func validateNotEmptyString() schema.SchemaValidateFunc {
6162
func objectMapToStringMap(rm map[string]interface{}) map[string]string {
6263
result := map[string]string{}
6364
for k, v := range rm {
64-
result[k] = v.(string)
65+
switch assertedValue := v.(type) {
66+
case string:
67+
result[k] = assertedValue
68+
default:
69+
// Make a best effort to coerce into a string, even if underlying type is not a string
70+
log.Printf("[DEBUG] non-string value encountered for key '%s' while converting object map to string map", k)
71+
result[k] = fmt.Sprintf("%v", assertedValue)
72+
}
6573
}
6674
return result
6775
}

0 commit comments

Comments
 (0)