Skip to content

Commit 8947e9d

Browse files
length check added before type assertion to avoid panic (#4184) (#2696)
Signed-off-by: Modular Magician <[email protected]>
1 parent d6cc890 commit 8947e9d

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

.changelog/4184.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
```release-note:bug
2+
storage - added length check for `cors` for the resource `resource_storage_bucket`
3+
4+
```

google-beta/resource_storage_bucket.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,9 @@ func resourceStorageBucketStateImporter(d *schema.ResourceData, meta interface{}
844844

845845
func expandCors(configured []interface{}) []*storage.BucketCors {
846846
corsRules := make([]*storage.BucketCors, 0, len(configured))
847+
if len(corsRules) == 0 {
848+
return nil
849+
}
847850
for _, raw := range configured {
848851
data := raw.(map[string]interface{})
849852
corsRule := storage.BucketCors{

0 commit comments

Comments
 (0)