Skip to content

Commit

Permalink
Fix crash caused by nil value in BigQuery Table (#10319) (#17721)
Browse files Browse the repository at this point in the history
[upstream:bfe6e935a2ecb1d1fc347b9aff11392d692be367]

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician committed Mar 28, 2024
1 parent b848632 commit 6cd9e80
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/10319.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
bigquery: fixed a crash when `google_bigquery_table` had a `primary_key.columns` entry set to `""`
```
5 changes: 5 additions & 0 deletions google/services/bigquery/resource_bigquery_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -2357,6 +2357,11 @@ func expandPrimaryKey(configured interface{}) *bigquery.TableConstraintsPrimaryK

columns := []string{}
for _, rawColumn := range raw["columns"].([]interface{}) {
if rawColumn == nil {
// Terraform reads "" as nil, which ends up crashing when we cast below
// sending "" to the API triggers a 400, which is okay.
rawColumn = ""
}
columns = append(columns, rawColumn.(string))
}
if len(columns) > 0 {
Expand Down

0 comments on commit 6cd9e80

Please sign in to comment.