From c4a9a955b0e30b4c033298f37ed391e427c4e65c Mon Sep 17 00:00:00 2001 From: Patrick Zhao Date: Thu, 13 Aug 2026 11:53:55 +0800 Subject: [PATCH] list scanning compatible with no repo Signed-off-by: Patrick Zhao --- .../aslan/core/workflow/testing/service/scanning.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/microservice/aslan/core/workflow/testing/service/scanning.go b/pkg/microservice/aslan/core/workflow/testing/service/scanning.go index 4f1810d926..17d24c8a7e 100644 --- a/pkg/microservice/aslan/core/workflow/testing/service/scanning.go +++ b/pkg/microservice/aslan/core/workflow/testing/service/scanning.go @@ -186,6 +186,8 @@ func ListCodeRepoScannings(ctx *internalhandler.Context, projectName string) ([] repoItemMap := make(map[string]*ListCodeRepoScanningRespItem) repoKeys := make([]string, 0) + // scannings that have no repo configured, they are grouped into a single item at the end of the response + noRepoScannings := make([]*CodeRepoScanning, 0) for _, scanning := range scanningList { res, err := ListScanningTask(scanning.ID.Hex(), 0, 0, ctx.Logger) @@ -214,9 +216,11 @@ func ListCodeRepoScannings(ctx *internalhandler.Context, projectName string) ([] UpdateBy: scanning.UpdatedBy, } - if len(scanning.Repos) == 0 { + if len(scanning.Repos) == 0 || scanning.Repos[0] == nil { + noRepoScannings = append(noRepoScannings, item) continue } + repo := scanning.Repos[0] namespace := repo.GetRepoNamespace() key := fmt.Sprintf("%d/%s/%s", repo.CodehostID, namespace, repo.RepoName) @@ -237,6 +241,13 @@ func ListCodeRepoScannings(ctx *internalhandler.Context, projectName string) ([] for _, key := range repoKeys { resp = append(resp, repoItemMap[key]) } + + if len(noRepoScannings) > 0 { + resp = append(resp, &ListCodeRepoScanningRespItem{ + CodeRepoScannings: noRepoScannings, + }) + } + return resp, int64(len(resp)), nil }