@@ -31,7 +31,7 @@ function checkAllSegmentsExist(segments: ISegmentsCacheBase): Promise<boolean> {
3131 * Exported for testing purposes.
3232 */
3333export function parseSegments ( ruleEntity : ISplit | IRBSegment , matcherType : typeof IN_SEGMENT | typeof IN_RULE_BASED_SEGMENT = IN_SEGMENT ) : Set < string > {
34- const { conditions = [ ] , excluded } = ruleEntity as IRBSegment ;
34+ const { conditions, excluded } = ruleEntity as IRBSegment ;
3535
3636 const segments = new Set < string > ( ) ;
3737 if ( excluded && excluded . segments ) {
@@ -42,12 +42,14 @@ export function parseSegments(ruleEntity: ISplit | IRBSegment, matcherType: type
4242 } ) ;
4343 }
4444
45- for ( let i = 0 ; i < conditions . length ; i ++ ) {
46- const matchers = conditions [ i ] . matcherGroup . matchers ;
45+ if ( conditions ) {
46+ for ( let i = 0 ; i < conditions . length ; i ++ ) {
47+ const matchers = conditions [ i ] . matcherGroup . matchers ;
4748
48- matchers . forEach ( matcher => {
49- if ( matcher . matcherType === matcherType ) segments . add ( matcher . userDefinedSegmentMatcherData . segmentName ) ;
50- } ) ;
49+ matchers . forEach ( matcher => {
50+ if ( matcher . matcherType === matcherType ) segments . add ( matcher . userDefinedSegmentMatcherData . segmentName ) ;
51+ } ) ;
52+ }
5153 }
5254
5355 return segments ;
@@ -88,7 +90,7 @@ function matchFilters(featureFlag: ISplit, filters: ISplitFiltersValidation) {
8890export function computeMutation < T extends ISplit | IRBSegment > ( rules : Array < T > , segments : Set < string > , filters ?: ISplitFiltersValidation ) : ISplitMutations < T > {
8991
9092 return rules . reduce ( ( accum , ruleEntity ) => {
91- if ( ruleEntity . status === 'ACTIVE ' && ( ! filters || matchFilters ( ruleEntity as ISplit , filters ) ) ) {
93+ if ( ruleEntity . status !== 'ARCHIVED ' && ( ! filters || matchFilters ( ruleEntity as ISplit , filters ) ) ) {
9294 accum . added . push ( ruleEntity ) ;
9395
9496 parseSegments ( ruleEntity ) . forEach ( ( segmentName : string ) => {
0 commit comments