@@ -228,7 +228,7 @@ func (e *EnvironmentService) ListEnvironments(projectID string, request *model.L
228
228
}
229
229
230
230
// Filtering based on given parameters
231
- if request .Filter != nil {
231
+ if request != nil && request .Filter != nil {
232
232
// Filtering based on chaos_infra name
233
233
if request .Filter .Name != nil && * request .Filter .Name != "" {
234
234
matchInfraNameStage := bson.D {
@@ -280,7 +280,7 @@ func (e *EnvironmentService) ListEnvironments(projectID string, request *model.L
280
280
var sortStage bson.D
281
281
282
282
switch {
283
- case request .Sort != nil && request .Sort .Field == model .EnvironmentSortingFieldTime :
283
+ case request != nil && request .Sort != nil && request .Sort .Field == model .EnvironmentSortingFieldTime :
284
284
// Sorting based on created time
285
285
if request .Sort .Ascending != nil && * request .Sort .Ascending {
286
286
sortStage = bson.D {
@@ -295,7 +295,7 @@ func (e *EnvironmentService) ListEnvironments(projectID string, request *model.L
295
295
}},
296
296
}
297
297
}
298
- case request .Sort != nil && request .Sort .Field == model .EnvironmentSortingFieldName :
298
+ case request != nil && request .Sort != nil && request .Sort .Field == model .EnvironmentSortingFieldName :
299
299
// Sorting based on ExperimentName time
300
300
if request .Sort .Ascending != nil && * request .Sort .Ascending {
301
301
sortStage = bson.D {
@@ -324,7 +324,7 @@ func (e *EnvironmentService) ListEnvironments(projectID string, request *model.L
324
324
sortStage ,
325
325
}
326
326
327
- if request .Pagination != nil {
327
+ if request != nil && request .Pagination != nil {
328
328
paginationSkipStage := bson.D {
329
329
{"$skip" , request .Pagination .Page * request .Pagination .Limit },
330
330
}
0 commit comments