Skip to content

feat(operators): add follow-up error scenarios for operator null-return behaviour#356

Open
aepfli wants to merge 1 commit intomainfrom
test/operator-error-followup
Open

feat(operators): add follow-up error scenarios for operator null-return behaviour#356
aepfli wants to merge 1 commit intomainfrom
test/operator-error-followup

Conversation

@aepfli
Copy link
Copy Markdown
Member

@aepfli aepfli commented Mar 30, 2026

Covers the remaining cases from open-feature/flagd#1874 identified in the review of #342:

  • starts_with / ends_with: non-string first argument → must return null
  • starts_with / ends_with: wrong argument count → must return null
  • sem_ver: wrong argument count (missing target version) → must return null
  • fractional: all-zero bucket weights (no bucket matched) → must return null
  • fractional: negative bucket weight clamped to zero → "one" gets effective weight 0, "two" gets 100% of the weight

All scenarios use a bare operator as the targeting expression (not wrapped in 'if') so a null result selects the defaultVariant directly. Scenarios are tagged @operator-errors and mirrored in both the SDK-level gherkin (gherkin/targeting.feature) and the evaluator-level gherkin files (evaluator/gherkin/{string,semver,fractional}.feature) with matching flag definitions added to both flags/edge-case-flags.json and evaluator/flags/testkit-flags.json.

This PR

  • adds this new feature

Related Issues

Fixes #1234523

Notes

Follow-up Tasks

How to test

@aepfli aepfli requested a review from a team as a code owner March 30, 2026 13:56
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces comprehensive test coverage for edge cases and error scenarios across several targeting operators, including string comparisons, semantic versioning, and fractional weighting. The added Gherkin scenarios and flag definitions ensure that invalid inputs or incorrect argument counts result in a fallback to the default variant rather than unexpected behavior. One review comment points out that the new flag configurations are duplicated across multiple JSON files, which could lead to maintenance challenges, and suggests centralizing these definitions if the framework permits.

@aepfli
Copy link
Copy Markdown
Member Author

aepfli commented Mar 30, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds several test cases and flag definitions to handle edge cases and error scenarios for targeting operators such as starts_with, ends_with, sem_ver, and fractional. These additions ensure that operators return null on error to correctly trigger default variant fallbacks and that negative weights in fractional targeting are clamped to zero. I have no feedback to provide.

@aepfli aepfli force-pushed the test/operator-error-followup branch from d17d0ed to db9d03f Compare March 30, 2026 14:51
…rn behaviour

Covers the remaining cases from open-feature/flagd#1874
identified in the review of #342:

- starts_with / ends_with: non-string first argument → must return null
- starts_with / ends_with: wrong argument count → must return null
- sem_ver: wrong argument count (missing target version) → must return null
- fractional: all-zero bucket weights (no bucket matched) → must return null
- fractional: negative bucket weight clamped to zero → "one" gets effective
  weight 0, "two" gets 100% of the weight

All scenarios use a bare operator as the targeting expression (not wrapped in
'if') so a null result selects the defaultVariant directly. Scenarios are
tagged @operator-errors and mirrored in both the SDK-level gherkin
(gherkin/targeting.feature) and the evaluator-level gherkin files
(evaluator/gherkin/{string,semver,fractional}.feature) with matching flag
definitions added to both flags/edge-case-flags.json and
evaluator/flags/testkit-flags.json.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com>
@aepfli aepfli force-pushed the test/operator-error-followup branch from db9d03f to 2c6d669 Compare March 30, 2026 18:18
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