This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/devlake.git
The following commit(s) were added to refs/heads/main by this push:
new 17af2a418 fix(plugins): return the opsgenie and pagerduty incidents
collector error (#9357)
17af2a418 is described below
commit 17af2a41893077383b7fcac04fc1a65d67f290b8
Author: Shivam Sharma <[email protected]>
AuthorDate: Tue Nov 10 17:04:40 2026 +0530
fix(plugins): return the opsgenie and pagerduty incidents collector error
(#9357)
CollectIncidents in both plugins returned nil when
NewStatefulApiCollectorForFinalizableEntity failed, e.g. when the
previous collector state couldn't be loaded or the cursor over
unfinished incidents failed. The subtask was marked successful without
collecting anything, and the error was lost. Return it, like the
Opsgenie teams and users collectors do.
Closes #9356
Generated-by: Claude Code (Claude Opus 5.5)
Signed-off-by: Shivam Sharma
<[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
.../plugins/opsgenie/tasks/incidents_collector.go | 2 +-
.../opsgenie/tasks/incidents_collector_test.go | 48 ++++++++++++++++++++++
.../plugins/pagerduty/tasks/incidents_collector.go | 2 +-
.../pagerduty/tasks/incidents_collector_test.go | 48 ++++++++++++++++++++++
4 files changed, 98 insertions(+), 2 deletions(-)
diff --git a/backend/plugins/opsgenie/tasks/incidents_collector.go
b/backend/plugins/opsgenie/tasks/incidents_collector.go
index 70100f149..6f346f19c 100644
--- a/backend/plugins/opsgenie/tasks/incidents_collector.go
+++ b/backend/plugins/opsgenie/tasks/incidents_collector.go
@@ -130,7 +130,7 @@ func CollectIncidents(taskCtx plugin.SubTaskContext)
errors.Error {
},
})
if err != nil {
- return nil
+ return err
}
return collector.Execute()
}
diff --git a/backend/plugins/opsgenie/tasks/incidents_collector_test.go
b/backend/plugins/opsgenie/tasks/incidents_collector_test.go
new file mode 100644
index 000000000..d0cfa0c81
--- /dev/null
+++ b/backend/plugins/opsgenie/tasks/incidents_collector_test.go
@@ -0,0 +1,48 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package tasks
+
+import (
+ "testing"
+
+ "github.com/apache/devlake/core/errors"
+ "github.com/apache/devlake/helpers/unithelper"
+ mockdal "github.com/apache/devlake/mocks/core/dal"
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/mock"
+)
+
+func TestCollectIncidentsReturnsCollectorSetupError(t *testing.T) {
+ // Loading the previous collector state fails, so the collector can't
be created.
+ dbErr := errors.Default.New("db unavailable")
+ mockDal := new(mockdal.Dal)
+ mockDal.On("First", mock.Anything, mock.Anything).Return(dbErr).Once()
+ mockDal.On("IsErrorNotFound", dbErr).Return(false).Once()
+
+ taskCtx := unithelper.DummySubTaskContext(mockDal)
+ taskCtx.On("GetData").Return(&OpsgenieTaskData{
+ Options: &OpsgenieOptions{ConnectionId: 1, ServiceId:
"service-1", ServiceName: "service"},
+ })
+
+ err := CollectIncidents(taskCtx)
+
+ if assert.NotNil(t, err) {
+ assert.Contains(t, err.Error(), "db unavailable")
+ }
+ mockDal.AssertExpectations(t)
+}
diff --git a/backend/plugins/pagerduty/tasks/incidents_collector.go
b/backend/plugins/pagerduty/tasks/incidents_collector.go
index 81cc20426..6d1862cd1 100644
--- a/backend/plugins/pagerduty/tasks/incidents_collector.go
+++ b/backend/plugins/pagerduty/tasks/incidents_collector.go
@@ -139,7 +139,7 @@ func CollectIncidents(taskCtx plugin.SubTaskContext)
errors.Error {
},
})
if err != nil {
- return nil
+ return err
}
return collector.Execute()
}
diff --git a/backend/plugins/pagerduty/tasks/incidents_collector_test.go
b/backend/plugins/pagerduty/tasks/incidents_collector_test.go
new file mode 100644
index 000000000..bc99d990c
--- /dev/null
+++ b/backend/plugins/pagerduty/tasks/incidents_collector_test.go
@@ -0,0 +1,48 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package tasks
+
+import (
+ "testing"
+
+ "github.com/apache/devlake/core/errors"
+ "github.com/apache/devlake/helpers/unithelper"
+ mockdal "github.com/apache/devlake/mocks/core/dal"
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/mock"
+)
+
+func TestCollectIncidentsReturnsCollectorSetupError(t *testing.T) {
+ // Loading the previous collector state fails, so the collector can't
be created.
+ dbErr := errors.Default.New("db unavailable")
+ mockDal := new(mockdal.Dal)
+ mockDal.On("First", mock.Anything, mock.Anything).Return(dbErr).Once()
+ mockDal.On("IsErrorNotFound", dbErr).Return(false).Once()
+
+ taskCtx := unithelper.DummySubTaskContext(mockDal)
+ taskCtx.On("GetData").Return(&PagerDutyTaskData{
+ Options: &PagerDutyOptions{ConnectionId: 1, ServiceId:
"service-1", ServiceName: "service"},
+ })
+
+ err := CollectIncidents(taskCtx)
+
+ if assert.NotNil(t, err) {
+ assert.Contains(t, err.Error(), "db unavailable")
+ }
+ mockDal.AssertExpectations(t)
+}