Skip to content

test: additional semver coverage and error assertions - #29

Open
greghuels wants to merge 2 commits into
DataDog:mainfrom
greghuels:greg.huels/semver-fix
Open

test: additional semver coverage and error assertions#29
greghuels wants to merge 2 commits into
DataDog:mainfrom
greghuels:greg.huels/semver-fix

Conversation

@greghuels

Copy link
Copy Markdown
Contributor

Promotes SEMVER_* behaviors that were only covered by Go/.NET unit tests into the shared system-test fixtures, so every FFE SDK exercises the same edge cases.

Changes

  • New semver-precedence-test flag + test-case-semver-precedence-flag.json (12 cases): multi-digit numeric prerelease ordering (beta.2 < beta.11), build-metadata-ignored across every operator (EQ/NEQ/LT/LTE/GT/GTE), and alphanumeric prerelease ordering (alpha < alpha.1 < alpha.beta < beta < release).
  • Extended test-case-semver-validation-flag.json (+12 cases): remaining SemVer §9 grammar rejections as attributes (empty, single/four components, leading-zero minor/patch, empty prerelease/build delimiters, underscore, multiple +, whitespace) and a non-string attribute (JSON number) → DEFAULT.
  • New test-case-semver-invalid-comparand-categories.json (6 cases): invalid comparand categories beyond overflow (invalid syntax, short, v-prefix, leading zero, non-string) → PARSE_ERROR, with a no-poisoning sanity case.

Verification

  • ci/validate-fixtures.py passes (298 cases, 44 flags, 40 files)
  • dd-trace-go TestEvaluateFlag_JSONFixtures: all 59 new semver cases pass
  • dd-trace-dotnet SemVer.cs/FeatureFlagsEvaluator.cs confirmed to match on non-string attribute (DEFAULT), non-string comparand (PARSE_ERROR), build-metadata-ignored, and numeric prerelease ordering

ufc-config.json is purely additive (6 new flags); no existing flags modified.

Add a waterfall flag whose non-last allocation carries an invalid configured
SemVer comparand, followed by a valid default allocation. Evaluating the
flag must return ERROR/PARSE_ERROR because the whole flag is rejected during
parsing; an implementation that skips the invalid allocation and falls
through to the default would instead return the fallback value with a
STATIC reason.

This directly encodes the scenario from libdatadog PR #2353 review comments
r3775906801 ('we only return default for the last allocation in a
waterfall') and r3775928397 ('invalid configuration should reject the whole
flag during parsing'), which the existing single-allocation
semver-invalid-comparand-test fixture could not distinguish from a
runtime skip-and-fall-through.
Audit of dd-trace-go's openfeature unit tests (semver_test.go,
evaluator_test.go, remoteconfig_test.go) found several SEMVER_* behaviors
that were only covered by Go/dotnet unit tests but absent from the shared
system-test fixtures. Since the shared fixtures are consumed by every FFE
SDK (Go, .NET, Java, JS, Python, Ruby, PHP, libdatadog), promote them so
all SDKs exercise the same edge cases.

New flag semver-precedence-test + test-case-semver-precedence-flag.json
(12 cases) isolates precedence rules that are easy to get wrong:
- Multi-digit numeric prerelease ordering (beta.2 < beta.11), the canonical
  lexicographic-trap bug
- Build metadata ignored across every operator (EQ/NEQ/LT/LTE/GT/GTE);
  previously only EQ was covered
- Alphanumeric prerelease ordering (alpha < alpha.1 < alpha.beta < beta <
  release)
Each allocation gates on a unique SEMVER_EQ attribute version so test
attributes cannot cross-match other allocations; negative build-metadata
cases (NEQ/LT/GT) fall through to DEFAULT.

Extended test-case-semver-validation-flag.json (+12 cases) covers the
remaining SemVer 2.0.0 9 grammar rejections as attributes (empty string,
single component, four components, leading-zero minor/patch, empty
prerelease/build delimiters, underscore, multiple + delimiters,
leading/trailing whitespace) and a non-string attribute (JSON number)
returning DEFAULT rather than erroring.

New test-case-semver-invalid-comparand-categories.json (6 cases) covers
invalid configured comparand categories beyond the overflow case already
exercised: invalid syntax (not-a-version), short (1.2), v-prefix (v1.2.3),
leading zero (01.2.3), and non-string (JSON number). Each rejects its flag
with PARSE_ERROR without poisoning the rest of the configuration.

All behaviors are spec-defined and SDK-agnostic. Verified:
- ci/validate-fixtures.py passes (298 cases, 44 flags, 40 files)
- dd-trace-go TestEvaluateFlag_JSONFixtures: all 59 new semver cases pass
- dd-trace-dotnet SemVer.cs/FeatureFlagsEvaluator.cs confirmed to match on
  non-string attribute (DEFAULT), non-string comparand (PARSE_ERROR),
  build-metadata-ignored, and numeric prerelease ordering

The ufc-config.json change is purely additive (6 new flags); no existing
flags were modified.
@greghuels
greghuels marked this pull request as ready for review August 14, 2026 09:37
@greghuels
greghuels requested a review from a team as a code owner August 14, 2026 09:37
@greghuels
greghuels requested review from pavlokhrebto and sameerank and removed request for a team August 14, 2026 09:37
@greghuels greghuels changed the title test: promote SEMVER_* unit-test coverage into shared system tests test: additional semver coverage and error assertions Aug 14, 2026
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.

1 participant