Skip to content

fix: remove if-wrappers from operator error flags#368

Closed
toddbaert wants to merge 1 commit intomainfrom
fix/remove-if-wrappers-operator-errors
Closed

fix: remove if-wrappers from operator error flags#368
toddbaert wants to merge 1 commit intomainfrom
fix/remove-if-wrappers-operator-errors

Conversation

@toddbaert
Copy link
Copy Markdown
Member

@toddbaert toddbaert commented Apr 20, 2026

The if wrappers were added in #356 (my bad), but json-logic's if coerces its condition to a boolean; null and false are both falsy, so the if always selects the "false" variant for both cases. This makes it impossible to verify that operators return null (not false) on error, which is the entire point of the @operator-errors scenarios.

By using the operator directly as the top-level targeting expression, a null return propagates to the evaluator, which falls back to defaultVariant with reason DEFAULT; a false return would resolve to the "false" variant with reason TARGETING_MATCH. The distinction is preserved.


I tested this locally and with this and the expected fixes, I was able to get the test suite fully updated in in-process mode! No more inconsistencies!

Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
@toddbaert toddbaert requested a review from a team as a code owner April 20, 2026 20:22
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 refactors flag targeting configurations by removing redundant if wrappers and updating variant names across testkit-flags.json and edge-case-flags.json. However, multiple review comments point out that for boolean-returning operators—specifically sem_ver, starts_with, and ends_with—renaming variants to match will break the evaluator's ability to resolve results. It is recommended to retain the true and false variants to ensure proper targeting resolution and to distinguish valid matches from error states.

Comment thread evaluator/flags/testkit-flags.json
"semver-invalid-operator-flag": {
"state": "ENABLED",
"variants": { "true": "true", "false": "false", "fallback": "fallback" },
"variants": { "match": "match", "fallback": "fallback" },
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

For boolean-returning operators like sem_ver, the variants should remain "true" and "false" to correctly handle valid results and preserve the distinction from null errors, as intended in the PR description.

Suggested change
"variants": { "match": "match", "fallback": "fallback" },
"variants": { "true": "true", "false": "false", "fallback": "fallback" },

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

These are edge cases. We WANT to test for null returns.

Comment thread evaluator/flags/testkit-flags.json
"ends-with-non-string-flag": {
"state": "ENABLED",
"variants": { "true": "true", "false": "false", "fallback": "fallback" },
"variants": { "match": "match", "fallback": "fallback" },
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The ends_with operator returns a boolean. The variants should be "true" and "false" to match the operator's output when it doesn't error.

Suggested change
"variants": { "match": "match", "fallback": "fallback" },
"variants": { "true": "true", "false": "false", "fallback": "fallback" },

Comment thread evaluator/flags/testkit-flags.json
Comment on lines +97 to 98
"match": "match",
"fallback": "fallback"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The starts_with operator returns a boolean. The variants should be "true" and "false".

        "true": "true",
        "false": "false",
        "fallback": "fallback"

Comment thread flags/edge-case-flags.json
Comment on lines +119 to 120
"match": "match",
"fallback": "fallback"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The starts_with operator returns a boolean. The variants should be "true" and "false".

        "true": "true",
        "false": "false",
        "fallback": "fallback"

Comment on lines +130 to 131
"match": "match",
"fallback": "fallback"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The ends_with operator returns a boolean. The variants should be "true" and "false".

        "true": "true",
        "false": "false",
        "fallback": "fallback"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comment on lines +169 to 170
"match": "match",
"fallback": "fallback"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The sem_ver operator returns a boolean. The variants should be "true" and "false".

        "true": "true",
        "false": "false",
        "fallback": "fallback"

@toddbaert toddbaert closed this Apr 20, 2026
@toddbaert toddbaert deleted the fix/remove-if-wrappers-operator-errors branch April 20, 2026 20:31
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