Skip to content

Commit

Permalink
Specifically handle nil map case
Browse files Browse the repository at this point in the history
  • Loading branch information
csmarchbanks committed Jul 10, 2024
1 parent 3fb6865 commit 9f08406
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/resources/machinelearning/resource_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ func alertFromModel(model resourceAlertModel) (mlapi.Alert, error) {
}

func labelsToMapValue(labels map[string]string) basetypes.MapValue {
if labels == nil {
return basetypes.NewMapNull(types.StringType)
}
values := map[string]attr.Value{}
for k, v := range labels {
values[k] = types.StringValue(v)
Expand All @@ -355,6 +358,9 @@ func labelsToMapValue(labels map[string]string) basetypes.MapValue {
}

func mapToLabels(m basetypes.MapValue) (map[string]string, error) {
if m.IsNull() {
return nil, nil
}
labels := map[string]string{}
for k, v := range m.Elements() {
if vString, ok := v.(types.String); ok {
Expand Down

0 comments on commit 9f08406

Please sign in to comment.