Skip to content

fix(core): isolate malformed FFE flags - #363

Draft
leoromanovsky wants to merge 1 commit into
mainfrom
agent/ffe-semver-malformed-flags
Draft

fix(core): isolate malformed FFE flags#363
leoromanovsky wants to merge 1 commit into
mainfrom
agent/ffe-semver-malformed-flags

Conversation

@leoromanovsky

Copy link
Copy Markdown
Collaborator

Motivation

The canonical FFE fixtures added through DataDog/ffe-system-test-data#26 require malformed flags to return ERROR/PARSE_ERROR without poisoning valid neighboring flags. The earlier Dependabot-only bump in #362 also exposed missing SemVer comparison support and is red in CI.

Changes

  • Bump the existing ffe-system-test-data submodule to ea8b5cc5ce335109f11f3efbc5fd608f98a3ca54.
  • Add strict SemVer 2.0 parsing and precedence for the six UFC SemVer operators.
  • Validate each flag's variations, condition operands, regexes, split shards, and shard bounds before evaluation.
  • Return ERROR with PARSE_ERROR for malformed flags while keeping the rest of the configuration usable.
  • Assert canonical fixture error codes in addition to values and reasons.

Decisions

  • Keep the repository's existing submodule-based fixture mechanism; this PR only advances its pinned revision.
  • Isolate invalid definitions per flag at the evaluator boundary instead of rejecting the entire configuration.
  • Treat invalid runtime SemVer attributes as non-matches, but treat invalid configured comparands as malformed flag configuration.
  • Implement SemVer comparison in core without adding a runtime dependency.

Validation:

  • yarn lint
  • yarn format:check
  • yarn workspace @datadog/flagging-core typecheck
  • yarn build
  • yarn test (518 tests)

Supersedes #362.

Implement strict SemVer comparison and isolate malformed flag definitions with PARSE_ERROR while preserving valid neighboring flags.

Environment: Datadog workspace
@leoromanovsky
leoromanovsky requested a balanced review from Copilot August 11, 2026 17:01
@leoromanovsky
leoromanovsky marked this pull request as ready for review August 11, 2026 17:02
@leoromanovsky
leoromanovsky requested a review from a team as a code owner August 11, 2026 17:02
@leoromanovsky
leoromanovsky requested review from btthomas and pavlokhrebto and removed request for a team August 11, 2026 17:02

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

Adds per-flag validation and SemVer operators while isolating malformed flags.

Changes:

  • Implements strict SemVer parsing and comparison.
  • Validates flag structures and returns PARSE_ERROR.
  • Updates canonical fixtures and error-code assertions.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/core/src/evaluation/evaluateForSubject.ts Adds per-flag validation and parse errors.
packages/core/src/evaluation/rules.ts Validates rules and evaluates SemVer operators.
packages/core/src/evaluation/semver.ts Implements SemVer parsing and precedence.
packages/core/test/TestCaseResult.types.ts Supports expected error codes.
packages/core/test/evaluation/flags-v1.spec.ts Asserts fixture error codes.
packages/core/test/ffe-system-test-data Advances canonical fixture revision.
packages/node-server/index.d.ts Exposes SemVer condition declarations.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

logger.debug(`returning default assignment because flag is disabled`, {
if (!isValidFlag(flag)) {
logger.debug(`returning default assignment because flag configuration is invalid`, {
flagKey: flag.key,
Comment on lines +164 to +166
if (!isVariantType(flag.variationType) || !isRecord(flag.variations) || !Array.isArray(flag.allocations)) {
return false
}
(split) =>
isRecord(split) &&
typeof split.variationKey === 'string' &&
split.variationKey in variations &&
@leoromanovsky
leoromanovsky marked this pull request as draft August 11, 2026 17:10
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.

2 participants