Skip to content

test(operators): add error return scenarios for custom operator null fallback#342

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

test(operators): add error return scenarios for custom operator null fallback#342
aepfli wants to merge 1 commit intomainfrom
test/operator-error-returns

Conversation

@aepfli
Copy link
Member

@aepfli aepfli commented Mar 12, 2026

Summary

Adds @operator-errors tagged scenarios to targeting.feature covering error return behavior from flagd#1874.

New Tag

@operator-errors — SDK implementations can opt in to verify their custom operators return null (not false) on error, which triggers the default variant fallback rather than the false branch of a conditional.

New Scenarios

All three scenarios use flags where the targeting rule is a bare operator call (not wrapped in if), so a null return triggers the default variant directly.

sem_ver with unparseable version (semver-invalid-version-flag)

Context passes not-a-version — sem_ver can't parse it, must return null → default variant fallback.

sem_ver with unknown operator (semver-invalid-operator-flag)

Rule uses === which is not a valid sem_ver operator — must return null → default variant fallback.

fractional with missing bucket key (fractional-null-bucket-key-flag)

Context is empty — bucket key variable resolves to null — must return null → default variant fallback.

Related

@aepfli aepfli requested a review from a team as a code owner March 12, 2026 15:15
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the testing suite by adding comprehensive scenarios for custom operator error handling. The primary goal is to ensure that when custom operators encounter invalid input or conditions, they correctly return a null value, which then triggers the intended default variant fallback. This improves the robustness and predictability of flag evaluation in error conditions.

Highlights

  • New Error Handling Scenarios: Introduced new Gherkin scenarios tagged with @operator-errors to specifically test the error return behavior of custom operators.
  • Null Fallback Verification: These scenarios verify that SDK implementations correctly return null (instead of false) when custom operators encounter errors, ensuring the default variant fallback mechanism is triggered.
  • Specific Test Cases: Added test cases for sem_ver operator with an unparseable version, sem_ver with an invalid operator, and fractional operator with a missing bucket key, all designed to trigger null returns and default variant fallbacks.
Changelog
  • flags/edge-case-flags.json
    • Added semver-invalid-version-flag to test sem_ver operator with unparseable version context.
    • Added semver-invalid-operator-flag to test sem_ver operator with an invalid operator.
    • Added fractional-null-bucket-key-flag to test fractional operator with a missing bucket key.
  • gherkin/targeting.feature
    • Added a new @operator-errors tagged scenario outline for custom operator error returns and default variant fallback.
    • Added a new @operator-errors tagged scenario for fractional operator with a missing bucket key falling back to the default variant.
Activity
  • No activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@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 test scenarios to verify that custom operators correctly return null on error, leading to the default variant fallback. The changes include new flag definitions in flags/edge-case-flags.json for sem_ver and fractional operator error conditions, and corresponding test scenarios in gherkin/targeting.feature. The implementation looks correct and covers the intended error cases. I've added one suggestion to improve the conciseness of a Gherkin Scenario Outline.

…l operators

Adds @operator-errors tagged scenarios verifying that custom operator errors
return null (triggering default variant fallback) rather than false (which
would take the false branch of a conditional):
- sem_ver with an unparseable version string
- sem_ver with an unknown comparison operator
- fractional with a missing/null bucket key

Addresses: open-feature/flagd#1874

Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@aepfli aepfli force-pushed the test/operator-error-returns branch from 72a8839 to a6a7234 Compare March 12, 2026 15:19
@aepfli
Copy link
Member Author

aepfli commented Mar 12, 2026

relates too open-feature/flagd#1874

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