Skip to content

fix: Align numeric trait conditions with flagsmith-engine - #118

Merged
emyller merged 2 commits into
mainfrom
fix/numeric-comparison
Oct 30, 2026
Merged

emyller merged 2 commits into
mainfrom
fix/numeric-comparison

Conversation

@emyller

@emyller emyller commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Local evaluation raises on some numeric trait conditions, and disagrees with flagsmith-engine on others.

Closes SDK-22. Tested by Flagsmith/engine-test-data#63.

Changes

  • Uncoercible rule values (e.g. 95 > "90.5") no longer raise or match; they don't match.
  • Float traits now coerce "90" to 90.0.
  • CONTAINS/NOT_CONTAINS on non-string traits no longer raise; they don't match.

🤖 Generated with Claude Code

…he other numeric type

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@emyller
emyller requested a review from a team as a code owner October 30, 2026 13:49
@emyller
emyller requested review from khvn26 and removed request for a team October 30, 2026 13:49
@linear-code

linear-code Bot commented Oct 30, 2026

Copy link
Copy Markdown

SDK-22

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 15 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 4703e5b0-67ca-47e6-89a4-64ed31195b68
Commits

Reviewing files that changed from the base of the PR and between fb2b0a7 and 9eb23e2.

Files selected for processing: 2
  • lib/flagsmith/engine/segments/models.rb
  • spec/engine/unit/segments/models_spec.rb

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: cac84c5a-21f0-4d07-93a2-ddf4fa41f735
Commits

Reviewing files that changed from the base of the PR and between 51544ab and fb2b0a7.

Files selected for processing: 2
  • lib/flagsmith/engine/segments/models.rb
  • spec/engine/unit/segments/models_spec.rb

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The segment condition matcher now returns false when type conversion or comparison raises ArgumentError. Float conversion uses Float(v, exception: false) and retains the original value when conversion returns nil. Unit cases add fractional comparisons for four ordering operators, including comparisons with integer-form and fractional condition values.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: Minimal · previous review fb2b0

The numeric segment comparison changes are consistent with the stated behavior and introduce no identified merge-blocking risk.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@emyller emyller self-assigned this Oct 30, 2026
@emyller
emyller marked this pull request as draft October 30, 2026 14:02
…raise on CONTAINS

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@emyller emyller changed the title fix: Stop raising when comparing a numeric trait to a rule value of the other numeric type fix: Align numeric trait conditions with flagsmith-engine Oct 30, 2026
@emyller
emyller marked this pull request as ready for review October 30, 2026 14:34
@emyller
emyller merged commit 5b154ca into main Oct 30, 2026
15 checks passed
@emyller
emyller deleted the fix/numeric-comparison branch October 30, 2026 14:41
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