Skip to content

Commit f27386f

Browse files
Fix error details type on google_database_migration_service_migration_job (#12858) (#9244)
[upstream:75e910a0c3f7b234c6d68f38f8d20ba0894ed52f] Signed-off-by: Modular Magician <[email protected]>
1 parent 1faad30 commit f27386f

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

.changelog/12858.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
fix: error details type on google_database_migration_service_migration_job
3+
```

google-beta/services/databasemigrationservice/resource_database_migration_service_migration_job.go

+23-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package databasemigrationservice
1919

2020
import (
21+
"encoding/json"
2122
"fmt"
2223
"log"
2324
"net/http"
@@ -843,7 +844,28 @@ func flattenDatabaseMigrationServiceMigrationJobErrorMessage(v interface{}, d *s
843844
}
844845

845846
func flattenDatabaseMigrationServiceMigrationJobErrorDetails(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
846-
return v
847+
if v == nil {
848+
return nil
849+
}
850+
detailsArray := v.([]interface{})
851+
for i, raw := range detailsArray {
852+
m := raw.(map[string]interface{})
853+
if len(m) < 1 {
854+
// Do not include empty json objects coming back from the api
855+
continue
856+
}
857+
for k, val := range m {
858+
if _, ok := val.(string); !ok {
859+
b, err := json.Marshal(v)
860+
if err != nil {
861+
return err
862+
}
863+
m[k] = string(b)
864+
}
865+
}
866+
detailsArray[i] = m
867+
}
868+
return detailsArray
847869
}
848870

849871
func flattenDatabaseMigrationServiceMigrationJobType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {

0 commit comments

Comments
 (0)