Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(condition): handling of missing source and/or target keys #277

Merged
merged 3 commits into from
Nov 26, 2024

Conversation

jtan-brex
Copy link
Contributor

@jtan-brex jtan-brex commented Nov 18, 2024

Description

Adds additional handling of missing source and/or target keys in condition package number equal to and string equal to.

Motivation and Context

Fix for issue:Condition Package Zero Value Matches Can Be Inaccurate #263.

Current behaviour of condition package does not contain source key or target key's object path existence check. This caused unexpected behaviour:

  • When only src key is present but the path doesn't exist, condition package inaccurately matches on zero value and empty string.

  • When both source key and target key are present but both paths do not exist, the number equal to and string equal to return true.

This adds checks thus

  • when source key or target key is present in condition package number equal to and string equal to, but either of path does not exist in the object, then condition equal to check return false.

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@jtan-brex jtan-brex marked this pull request as ready for review November 20, 2024 16:05
@jtan-brex jtan-brex requested a review from a team as a code owner November 20, 2024 16:05
@@ -134,6 +134,70 @@ var numberEqualToTests = []struct {
[]byte(`{"foo": 100, "bar": 200}`),
false,
},
{
"pass",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any tests that return false should be labeled as "fail" ("pass" is for tests that return true).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

gotcha, thanks for pointing that out! fixed test cases to reflect expected 'fail' outcomes.

@jshlbrd jshlbrd self-assigned this Nov 21, 2024
Copy link
Collaborator

@jshlbrd jshlbrd left a comment

Choose a reason for hiding this comment

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

There will need to be more work on this prior to the next major update. I think we can do this in more places, but not everywhere without introducing a breaking change.

@jtan-brex jtan-brex merged commit 090981b into main Nov 26, 2024
7 checks passed
@jtan-brex jtan-brex deleted the jtan-fix-issue-263 branch November 26, 2024 14:20
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