@@ -735,7 +735,13 @@ func (impl *CdHandlerImpl) FetchAppWorkflowStatusForTriggerViewForEnvironment(re
735
735
// filter out pipelines for unauthorized apps but not envs
736
736
appResults , _ := request .CheckAuthBatch (token , appObjectArr , envObjectArr )
737
737
for _ , pipeline := range pipelines {
738
- appObject := objects [pipeline .Id ][0 ]
738
+ // Safety check to prevent index-out-of-range panic
739
+ objectArr , ok := objects [pipeline .Id ]
740
+ if ! ok {
741
+ impl .Logger .Warnw ("skipping pipeline with missing object data" , "pipelineId" , pipeline .Id )
742
+ continue
743
+ }
744
+ appObject := objectArr [0 ]
739
745
if ! (appResults [appObject ]) {
740
746
// if user unauthorized, skip items
741
747
continue
@@ -872,13 +878,24 @@ func (impl *CdHandlerImpl) FetchAppDeploymentStatusForEnvironments(request resou
872
878
objects := impl .enforcerUtil .GetAppAndEnvObjectByPipelineIds (pipelineIds )
873
879
pipelineIds = []int {}
874
880
for _ , object := range objects {
875
- appObjectArr = append (appObjectArr , object [0 ])
876
- envObjectArr = append (envObjectArr , object [1 ])
881
+ // Safety check to prevent index out of range panic
882
+ if len (object ) >= 2 {
883
+ appObjectArr = append (appObjectArr , object [0 ])
884
+ envObjectArr = append (envObjectArr , object [1 ])
885
+ } else {
886
+ impl .Logger .Warnw ("skipping object with insufficient elements" , "object" , object )
887
+ }
877
888
}
878
889
appResults , envResults := request .CheckAuthBatch (token , appObjectArr , envObjectArr )
879
890
for _ , pipeline := range cdPipelines {
880
- appObject := objects [pipeline .Id ][0 ]
881
- envObject := objects [pipeline .Id ][1 ]
891
+ // Safety check to prevent index out of range panic
892
+ objectArr , ok := objects [pipeline .Id ]
893
+ if ! ok || len (objectArr ) < 2 {
894
+ impl .Logger .Warnw ("skipping pipeline with missing object data" , "pipelineId" , pipeline .Id )
895
+ continue
896
+ }
897
+ appObject := objectArr [0 ]
898
+ envObject := objectArr [1 ]
882
899
if ! (appResults [appObject ] && envResults [envObject ]) {
883
900
// if user unauthorized, skip items
884
901
continue
0 commit comments