[FSSDK-12880] Refactor project config creation#1164
Merged
Conversation
- Simplify createProjectConfig to accept a datafile string directly instead of string | object, inlining datafile validation - Remove the separate config_validator module and its tests - Break monolithic config builder into focused parse functions: parseAudienceConfig, parseAttributeConfig, parseGroupConfig, parseRolloutConfig, parseIntegrationConfig, parseExperimentConfig, parseFeatureFlagConfig - Eliminate mutation-safe datafile copy in favor of direct construction - Refactor redundant iterations over experiments and feature flags - Remove lodash dev dependency Benchmarks show ~10% faster config parsing for 3-4 MB datafiles. Removing createMutationSafeDatafileCopy also fixes a memory issue where it allocated ~4x the datafile size in shallow copies per call, causing OOM under repeated parsing of large datafiles. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors project config creation to parse directly from a datafile JSON string, removes the standalone config_validator module (and its tests), and drops lodash as a dev dependency. The refactor also splits config parsing into more focused parse functions and streamlines iteration over experiments/feature flags for better performance and memory usage.
Changes:
- Change
createProjectConfigto accept a datafile JSON string, inline basic parsing/version validation, and removetryCreatingProjectConfig. - Refactor config parsing into focused
parse*helpers and reduce redundant iteration over rules/variations. - Remove
config_validatorand lodash usage across tests; update call sites and mocks to pass JSON strings.
Reviewed changes
Copilot reviewed 25 out of 26 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Removes lodash dev dependency. |
| package-lock.json | Updates lockfile due to dependency changes (includes several transitive bumps). |
| lib/utils/config_validator/index.ts | Removes datafile validation module (superseded by inline validation). |
| lib/utils/config_validator/index.tests.js | Removes mocha tests for config_validator. |
| lib/utils/config_validator/index.spec.ts | Removes vitest tests for config_validator. |
| lib/tests/mock/mock_datafile_manager.ts | Updates mock DatafileManager to operate on string datafiles only. |
| lib/project_config/project_config.ts | Refactors config parsing, inlines JSON parsing/version validation, removes tryCreatingProjectConfig. |
| lib/project_config/project_config.tests.js | Updates tests to pass stringified datafiles; adjusts expectations for ordering. |
| lib/project_config/project_config.spec.ts | Updates TS tests to pass stringified datafiles; updates option-based validation tests. |
| lib/project_config/project_config_manager.ts | Switches to createProjectConfig(datafileStr, options) and updates types to string-only datafile. |
| lib/project_config/project_config_manager.spec.ts | Updates config manager specs to use stringified datafiles and updated validation behavior. |
| lib/project_config/optimizely_config.tests.js | Removes lodash cloneDeep usage; updates to stringified createProjectConfig calls. |
| lib/project_config/optimizely_config.spec.ts | Removes local cloneDeep helper; updates to stringified createProjectConfig calls. |
| lib/optimizely/index.tests.js | Updates mock configs to use stringified createProjectConfig calls. |
| lib/optimizely/index.spec.ts | Updates TS tests to use stringified createProjectConfig calls. |
| lib/optimizely_user_context/index.tests.js | Updates tests to use stringified createProjectConfig calls. |
| lib/optimizely_user_context/index.spec.ts | Updates TS tests to use stringified createProjectConfig calls. |
| lib/index.react_native.spec.ts | Removes config_validator import; updates commented examples to stringified createProjectConfig. |
| lib/index.node.tests.js | Removes config_validator import; updates commented examples to stringified createProjectConfig. |
| lib/index.browser.umdtests.js | Removes config_validator usage in UMD tests. |
| lib/index.browser.tests.js | Removes config_validator import; updates to stringified createProjectConfig in mocks. |
| lib/event_processor/event_builder/user_event.spec.ts | Updates tests to pass stringified datafiles to createProjectConfig. |
| lib/core/decision_service/index.tests.js | Updates tests to use stringified createProjectConfig calls. |
| lib/core/decision_service/index.spec.ts | Updates TS tests to use stringified createProjectConfig calls. |
| lib/core/bucketer/index.tests.js | Updates tests to use stringified createProjectConfig calls. |
| lib/core/bucketer/index.spec.ts | Updates TS tests to use stringified createProjectConfig calls. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
junaed-optimizely
approved these changes
Jul 8, 2026
junaed-optimizely
left a comment
Contributor
There was a problem hiding this comment.
Good improvement! LGTM! I have just added one non-blocking comment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Benchmarks show ~10% faster config parsing for 3-4 MB datafiles. Removing createMutationSafeDatafileCopy also fixes a memory issue where it allocated ~4x the datafile size in shallow copies per call, causing OOM under repeated parsing of large datafiles.
Test plan
Issues