Skip to content

Commit a8e7f79

Browse files
committed
handling edge cases
1 parent 6c2d47b commit a8e7f79

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

internal/powerplatform/services/data_record/api_data_record.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (client *DataRecordClient) GetDataRecord(ctx context.Context, recordId stri
122122
_, err = client.Api.Execute(ctx, "GET", apiUrl.String(), nil, nil, []int{http.StatusOK}, &result)
123123
if err != nil {
124124
if strings.ContainsAny(err.Error(), "404") {
125-
return nil, powerplatform_helpers.WrapIntoProviderError(err, powerplatform_helpers.ERROR_OBJECT_NOT_FOUND, fmt.Sprintf("DLP Policy '%s' not found", recordId))
125+
return nil, powerplatform_helpers.WrapIntoProviderError(err, powerplatform_helpers.ERROR_OBJECT_NOT_FOUND, fmt.Sprintf("Data Record '%s' not found", recordId))
126126
}
127127
return nil, err
128128
}
@@ -153,7 +153,17 @@ func (client *DataRecordClient) GetRelationData(ctx context.Context, recordId st
153153
return nil, err
154154
}
155155

156-
return result["value"].([]interface{}), nil
156+
field, ok := result["value"]
157+
if !ok {
158+
return nil, fmt.Errorf("value field not found in result")
159+
}
160+
161+
value, ok := field.([]interface{})
162+
if !ok {
163+
return nil, fmt.Errorf("value field is not of type []interface{}")
164+
}
165+
166+
return value, nil
157167
}
158168

159169
func (client *DataRecordClient) GetEntityRelationDefinitionInfo(ctx context.Context, environmentId string, entityLogicalName string, relationLogicalName string) (tableName string) {

0 commit comments

Comments
 (0)