Skip to content

Commit 421df9e

Browse files
committed
return error if appIdName is not in proper format
1 parent 239ca31 commit 421df9e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pkg/app/AppListingViewBuilder.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package app
1818

1919
import (
20+
"errors"
2021
"github.com/devtron-labs/devtron/api/bean"
2122
"github.com/devtron-labs/devtron/internal/sql/repository/helper"
2223
"go.uber.org/zap"
@@ -60,12 +61,16 @@ func (impl *AppListingViewBuilderImpl) BuildView(fetchAppListingRequest FetchApp
6061

6162
var appContainersResponses []*bean.AppContainer
6263
for k, v := range filteredAppEnvMap {
63-
appId, err := strconv.Atoi(strings.Split(k, "_")[0])
64+
appIdAndName := strings.Split(k, "_")
65+
if len(appIdAndName) != 2 {
66+
return []*bean.AppContainer{}, errors.New("invalid format for app id and name. It should be in format <appId>_<appName>")
67+
}
68+
appId, err := strconv.Atoi(appIdAndName[0])
6469
if err != nil {
6570
impl.Logger.Error("err", err)
6671
return []*bean.AppContainer{}, nil
6772
}
68-
appName := strings.Split(k, "_")[1]
73+
appName := appIdAndName[1]
6974
defaultEnv := bean.AppEnvironmentContainer{}
7075
projectId := 0
7176
for _, env := range v {

0 commit comments

Comments
 (0)