Skip to content

Commit 80d1377

Browse files
galachadklesh
andauthored
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 <[email protected]>
1 parent e434e0d commit 80d1377

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

backend/plugins/gitextractor/tasks/repo_cloner.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ var CloneGitRepoMeta = plugin.SubTaskMeta{
3939
func CloneGitRepo(subTaskCtx plugin.SubTaskContext) errors.Error {
4040
taskData, ok := subTaskCtx.GetData().(*parser.GitExtractorTaskData)
4141
if !ok {
42-
panic("git repo reference not found on context")
42+
subTaskCtx.GetLogger().Error(nil, "git repo reference not found on context")
43+
return errors.Default.New("git repo reference not found on context")
4344
}
4445
op := taskData.Options
4546
storage := store.NewDatabase(subTaskCtx, op.RepoId)

backend/plugins/gitextractor/tasks/repo_collector.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,12 @@ func CollectGitDiffLines(subTaskCtx plugin.SubTaskContext) errors.Error {
8484
func getGitRepo(subTaskCtx plugin.SubTaskContext) parser.RepoCollector {
8585
taskData, ok := subTaskCtx.GetData().(*parser.GitExtractorTaskData)
8686
if !ok {
87-
panic("git repo reference not found on context")
87+
subTaskCtx.GetLogger().Error(nil, "git repo reference not found on context")
88+
return nil
8889
}
8990
if taskData.GitRepo == nil {
90-
panic("git repo is empty, please check subtask: clone repo")
91+
subTaskCtx.GetLogger().Error(nil, "git repo is empty, skipping Collect Commits subtask")
92+
return nil
9193
}
9294
return taskData.GitRepo
9395
}

0 commit comments

Comments
 (0)