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 aeccf3f31 fix(github): return the issue extractor setup errors (#9359)
aeccf3f31 is described below

commit aeccf3f31453a43159c29340282ce030c2a5f37a
Author: Shivam Sharma <[email protected]>
AuthorDate: Wed Nov 11 08:35:42 2026 +0530

    fix(github): return the issue extractor setup errors (#9359)
    
    ExtractApiIssues and the github_graphql ExtractIssues returned nil when
    NewIssueRegexes failed, e.g. on an invalid issue regex in the scope
    config. The github_graphql extractor did the same when the milestone
    query failed. The subtask was marked successful without extracting
    anything, and the error was lost. Return it, like the PR extractors do.
    
    Closes #9358
    
    Generated-by: Claude Code (Claude Opus 5.5)
    
    Signed-off-by: Shivam Sharma 
<[email protected]>
    Co-authored-by: Claude Opus 5.5 <[email protected]>
---
 backend/plugins/github/tasks/issue_extractor.go    |  2 +-
 .../plugins/github/tasks/issue_extractor_test.go   | 21 +++++++
 .../github_graphql/tasks/issue_extractor.go        |  4 +-
 .../github_graphql/tasks/issue_extractor_test.go   | 70 ++++++++++++++++++++++
 4 files changed, 94 insertions(+), 3 deletions(-)

diff --git a/backend/plugins/github/tasks/issue_extractor.go 
b/backend/plugins/github/tasks/issue_extractor.go
index 2f80c9286..575ff1527 100644
--- a/backend/plugins/github/tasks/issue_extractor.go
+++ b/backend/plugins/github/tasks/issue_extractor.go
@@ -91,7 +91,7 @@ func ExtractApiIssues(taskCtx plugin.SubTaskContext) 
errors.Error {
        config := data.Options.ScopeConfig
        issueRegexes, err := NewIssueRegexes(config)
        if err != nil {
-               return nil
+               return err
        }
 
        extractor, extErr := 
api.NewStatefulApiExtractor(&api.StatefulApiExtractorArgs[IssuesResponse]{
diff --git a/backend/plugins/github/tasks/issue_extractor_test.go 
b/backend/plugins/github/tasks/issue_extractor_test.go
index b8294240a..341cd5a4b 100644
--- a/backend/plugins/github/tasks/issue_extractor_test.go
+++ b/backend/plugins/github/tasks/issue_extractor_test.go
@@ -21,6 +21,9 @@ import (
        "testing"
        "time"
 
+       "github.com/apache/devlake/helpers/unithelper"
+       mockdal "github.com/apache/devlake/mocks/core/dal"
+       "github.com/apache/devlake/plugins/github/models"
        "github.com/stretchr/testify/assert"
 )
 
@@ -40,3 +43,21 @@ func TestIssueLeadTimeMinutes(t *testing.T) {
        // Closed before created, as GitHub reports for some transferred issues.
        assert.Nil(t, IssueLeadTimeMinutes(createdAt, 
createdAt.Add(-44*time.Minute)))
 }
+
+func TestExtractApiIssuesReturnsIssueRegexError(t *testing.T) {
+       mockDal := new(mockdal.Dal)
+       taskCtx := unithelper.DummySubTaskContext(mockDal)
+       taskCtx.On("GetData").Return(&GithubTaskData{
+               Options: &GithubOptions{
+                       ConnectionId: 1,
+                       Name:         "apache/devlake",
+                       ScopeConfig:  &models.GithubScopeConfig{IssueSeverity: 
"severity/(.*"},
+               },
+       })
+
+       err := ExtractApiIssues(taskCtx)
+
+       if assert.NotNil(t, err) {
+               assert.Contains(t, err.Error(), "issueSeverity")
+       }
+}
diff --git a/backend/plugins/github_graphql/tasks/issue_extractor.go 
b/backend/plugins/github_graphql/tasks/issue_extractor.go
index 3f15bd0d9..7b05aaaec 100644
--- a/backend/plugins/github_graphql/tasks/issue_extractor.go
+++ b/backend/plugins/github_graphql/tasks/issue_extractor.go
@@ -47,11 +47,11 @@ func ExtractIssues(taskCtx plugin.SubTaskContext) 
errors.Error {
        config := data.Options.ScopeConfig
        issueRegexes, err := githubTasks.NewIssueRegexes(config)
        if err != nil {
-               return nil
+               return err
        }
        milestoneMap, err := getMilestoneMap(db, data.Options.GithubId, 
data.Options.ConnectionId)
        if err != nil {
-               return nil
+               return err
        }
 
        extractor, err := api.NewApiExtractor(api.ApiExtractorArgs{
diff --git a/backend/plugins/github_graphql/tasks/issue_extractor_test.go 
b/backend/plugins/github_graphql/tasks/issue_extractor_test.go
new file mode 100644
index 000000000..d1b9f2fba
--- /dev/null
+++ b/backend/plugins/github_graphql/tasks/issue_extractor_test.go
@@ -0,0 +1,70 @@
+/*
+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/apache/devlake/plugins/github/models"
+       githubTasks "github.com/apache/devlake/plugins/github/tasks"
+       "github.com/stretchr/testify/assert"
+       "github.com/stretchr/testify/mock"
+)
+
+func TestExtractIssuesReturnsIssueRegexError(t *testing.T) {
+       mockDal := new(mockdal.Dal)
+       taskCtx := unithelper.DummySubTaskContext(mockDal)
+       taskCtx.On("GetData").Return(&githubTasks.GithubTaskData{
+               Options: &githubTasks.GithubOptions{
+                       ConnectionId: 1,
+                       Name:         "apache/devlake",
+                       ScopeConfig:  &models.GithubScopeConfig{IssueSeverity: 
"severity/(.*"},
+               },
+       })
+
+       err := ExtractIssues(taskCtx)
+
+       if assert.NotNil(t, err) {
+               assert.Contains(t, err.Error(), "issueSeverity")
+       }
+}
+
+func TestExtractIssuesReturnsMilestoneQueryError(t *testing.T) {
+       dbErr := errors.Default.New("db unavailable")
+       mockDal := new(mockdal.Dal)
+       mockDal.On("All", mock.Anything, mock.Anything).Return(dbErr).Once()
+       taskCtx := unithelper.DummySubTaskContext(mockDal)
+       taskCtx.On("GetData").Return(&githubTasks.GithubTaskData{
+               Options: &githubTasks.GithubOptions{
+                       ConnectionId: 1,
+                       GithubId:     101,
+                       Name:         "apache/devlake",
+                       ScopeConfig:  &models.GithubScopeConfig{},
+               },
+       })
+
+       err := ExtractIssues(taskCtx)
+
+       if assert.NotNil(t, err) {
+               assert.Contains(t, err.Error(), "db unavailable")
+       }
+       mockDal.AssertExpectations(t)
+}

Reply via email to