You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by kl...@apache.org on 2025/04/28 09:22:45 UTC

(incubator-devlake) branch main updated: fix: replace panic in gitextractor with error handling (#8386)

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/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new 80d1377f3 fix: replace panic in gitextractor with error handling (#8386)
80d1377f3 is described below

commit 80d1377f326847da1ba73f9e21c6b5cd416b85c3
Author: Adam Foryƛ <ad...@gmail.com>
AuthorDate: Mon Apr 28 11:22:41 2025 +0200

    fix: replace panic in gitextractor with error handling (#8386)
    
    * replace panic in gitextractor with error handling.
    
    * Fix subTaskCtx.GetLogger().Error arguments
    
    ---------
    
    Co-authored-by: Klesh Wong <zh...@merico.dev>
---
 backend/plugins/gitextractor/tasks/repo_cloner.go    | 3 ++-
 backend/plugins/gitextractor/tasks/repo_collector.go | 6 ++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/backend/plugins/gitextractor/tasks/repo_cloner.go b/backend/plugins/gitextractor/tasks/repo_cloner.go
index c72841105..d4efd278d 100644
--- a/backend/plugins/gitextractor/tasks/repo_cloner.go
+++ b/backend/plugins/gitextractor/tasks/repo_cloner.go
@@ -39,7 +39,8 @@ var CloneGitRepoMeta = plugin.SubTaskMeta{
 func CloneGitRepo(subTaskCtx plugin.SubTaskContext) errors.Error {
 	taskData, ok := subTaskCtx.GetData().(*parser.GitExtractorTaskData)
 	if !ok {
-		panic("git repo reference not found on context")
+		subTaskCtx.GetLogger().Error(nil, "git repo reference not found on context")
+		return errors.Default.New("git repo reference not found on context")
 	}
 	op := taskData.Options
 	storage := store.NewDatabase(subTaskCtx, op.RepoId)
diff --git a/backend/plugins/gitextractor/tasks/repo_collector.go b/backend/plugins/gitextractor/tasks/repo_collector.go
index 23fbe1734..42da50551 100644
--- a/backend/plugins/gitextractor/tasks/repo_collector.go
+++ b/backend/plugins/gitextractor/tasks/repo_collector.go
@@ -84,10 +84,12 @@ func CollectGitDiffLines(subTaskCtx plugin.SubTaskContext) errors.Error {
 func getGitRepo(subTaskCtx plugin.SubTaskContext) parser.RepoCollector {
 	taskData, ok := subTaskCtx.GetData().(*parser.GitExtractorTaskData)
 	if !ok {
-		panic("git repo reference not found on context")
+		subTaskCtx.GetLogger().Error(nil, "git repo reference not found on context")
+		return nil
 	}
 	if taskData.GitRepo == nil {
-		panic("git repo is empty, please check subtask: clone repo")
+		subTaskCtx.GetLogger().Error(nil, "git repo is empty, skipping Collect Commits subtask")
+		return nil
 	}
 	return taskData.GitRepo
 }