Skip to content

[FSSDK-12880] Refactor project config creation#1164

Merged
raju-opti merged 2 commits into
masterfrom
raju/config-refactor
Jul 8, 2026
Merged

[FSSDK-12880] Refactor project config creation#1164
raju-opti merged 2 commits into
masterfrom
raju/config-refactor

Conversation

@raju-opti

Copy link
Copy Markdown
Contributor

Summary

  • 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.

Test plan

  • all existing tests pass after the modification to accommodate the API change

Issues

  • FSSDK-12880

- 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>
@coveralls

coveralls commented Jul 8, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 77.724% (+0.02%) from 77.701% — raju/config-refactor into master

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 createProjectConfig to accept a datafile JSON string, inline basic parsing/version validation, and remove tryCreatingProjectConfig.
  • Refactor config parsing into focused parse* helpers and reduce redundant iteration over rules/variations.
  • Remove config_validator and 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.

Comment thread lib/project_config/project_config.ts
Comment thread lib/project_config/project_config.ts

@junaed-optimizely junaed-optimizely left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good improvement! LGTM! I have just added one non-blocking comment

Comment thread lib/project_config/project_config.spec.ts Outdated
@raju-opti raju-opti merged commit ccaf38b into master Jul 8, 2026
23 of 25 checks passed
@raju-opti raju-opti deleted the raju/config-refactor branch July 8, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants