diff --git a/src/lib/features/playground/playground-service.ts b/src/lib/features/playground/playground-service.ts index 8af5d726ee..3e5f76cd90 100644 --- a/src/lib/features/playground/playground-service.ts +++ b/src/lib/features/playground/playground-service.ts @@ -48,6 +48,7 @@ export class PlaygroundService { projects: typeof ALL | string[], environments: string[], context: SdkContextSchema, + limit: number, ): Promise { const segments = await this.segmentService.getActive(); const environmentFeatures = await Promise.all( @@ -59,6 +60,7 @@ export class PlaygroundService { environments.length, environmentFeatures[0]?.features.length ?? 0, contexts.length, + limit, ); const results = await Promise.all( diff --git a/src/lib/features/playground/playground.ts b/src/lib/features/playground/playground.ts index eb21177bbc..122f1c4ec3 100644 --- a/src/lib/features/playground/playground.ts +++ b/src/lib/features/playground/playground.ts @@ -106,12 +106,19 @@ export default class PlaygroundController extends Controller { res: Response, ): Promise { if (this.flagResolver.isEnabled('advancedPlayground')) { + const { payload } = + this.flagResolver.getVariant('advancedPlayground'); + const limit = + payload?.value && Number.isInteger(parseInt(payload?.value)) + ? parseInt(payload?.value) + : 15000; res.json({ input: req.body, features: await this.playgroundService.evaluateAdvancedQuery( req.body.projects || '*', req.body.environments, req.body.context, + limit, ), }); } else { diff --git a/src/lib/features/playground/validateQueryComplexity.ts b/src/lib/features/playground/validateQueryComplexity.ts index 2106455c46..117de5ae80 100644 --- a/src/lib/features/playground/validateQueryComplexity.ts +++ b/src/lib/features/playground/validateQueryComplexity.ts @@ -6,6 +6,7 @@ export const validateQueryComplexity = ( environmentsCount: number, featuresCount: number, contextCombinationsCount: number, + limit = MAX_COMPLEXITY, ): void => { const totalCount = environmentsCount * featuresCount * contextCombinationsCount; @@ -13,7 +14,7 @@ export const validateQueryComplexity = ( const reason = `Rejecting evaluation as it would generate ${totalCount} combinations exceeding ${MAX_COMPLEXITY} limit. `; const action = `Please reduce the number of selected environments (${environmentsCount}), features (${featuresCount}), context field combinations (${contextCombinationsCount}).`; - if (totalCount > MAX_COMPLEXITY) { + if (totalCount > limit) { throw new BadDataError(reason + action); } };