Skip to content

Fix numeric comparison in evaluate bug#424

Closed
laander wants to merge 3 commits intoreflagcom:mainfrom
laander:main
Closed

Fix numeric comparison in evaluate bug#424
laander wants to merge 3 commits intoreflagcom:mainfrom
laander:main

Conversation

@laander
Copy link
Contributor

@laander laander commented Jun 18, 2025

In local evaluation for the Node SDK:

Fix numeric comparison for GT/LT operators where casting strings to numbers wasn't being done correctly happen.
That could result in situations where "2" > "10" == true

Added test case

@laander laander requested review from Copilot and roncohen June 18, 2025 10:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the numeric comparison bug in the Node SDK's evaluation function by correctly converting string representations of numbers to numeric values.

  • Updated numeric comparisons in the evaluation function for GT and LT operators.
  • Added test cases to validate the fix for numeric comparisons when values are provided as strings.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/flag-evaluation/test/index.test.ts Added test cases to validate numeric comparisons.
packages/flag-evaluation/src/index.ts Modified GT and LT operators to perform numeric conversions.

@laander
Copy link
Contributor Author

laander commented Jun 18, 2025

Superceded by #426 because this PR was created from another remote (forked repo) which meant that GH actions build and test wouldn't run

@laander laander closed this Jun 18, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jun 18, 2025
In local evaluation for the Node SDK:

Fix numeric comparison for GT/LT operators where casting strings to
numbers wasn't being done correctly happen.
That could result in situations where "2" > "10" == true

Added test case

Note: replaces
#424 which was
created from another remote (forked repo) which meant that GH actions
build and test wouldn't run
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