Skip to content

fix(utils): compare numeric attribute-filter literals as strings#115

Open
joshuarobinson wants to merge 1 commit into
mainfrom
fix/mr500-attribute-filter-number-equality
Open

fix(utils): compare numeric attribute-filter literals as strings#115
joshuarobinson wants to merge 1 commit into
mainfrom
fix/mr500-attribute-filter-number-equality

Conversation

@joshuarobinson

@joshuarobinson joshuarobinson commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

In the attribute filter grammar, the number transformer returned a float, but compare() evaluates '=' / '!=' as
str(metadata[key]) value. Comparing a string against a float made equality on an unquoted numeric literal always fail (and inequality always succeed) for string-typed metadata, e.g. 'priority = 10' never matched {'priority': '10'}. Return the literal as a string so equality works; ordering operators are unaffected since they coerce both operands with float().

Found in merged MR !500.

Checklist

  • Development PR
    • .release_notes/.unreleased.md
      • Notable changes to the client (i.e. not related to tooling, CI/CD, etc.) from this PR have been added.
  • Release PR
    • CI/CD
      • The default branch pipelines are passing in both GitHub + GitLab (latter for SwiftStack E2E tests).
    • multi-storage-client/pyproject.toml
      • The package version has been bumped.
    • .release_notes/.unreleased.md
      • This file's contents have been moved into a .release_notes/{bumped package version}.md file.

Summary by CodeRabbit

  • Bug Fixes
    • Improved attribute-filter comparisons involving numeric metadata values.
    • Numeric filter values are now handled consistently as strings for equality and inequality checks, while ordering comparisons continue to work numerically.

In the attribute filter grammar, the number transformer returned a
float, but compare() evaluates '=' / '!=' as
str(metadata[key]) <op> value. Comparing a string against a float made
equality on an unquoted numeric literal always fail (and inequality
always succeed) for string-typed metadata, e.g. 'priority = 10' never
matched {'priority': '10'}. Return the literal as a string so equality
works; ordering operators are unaffected since they coerce both operands
with float().

Found in merged MR !500.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@joshuarobinson
joshuarobinson requested a review from a team July 19, 2026 16:11
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8beeba4c-d909-48ae-a8f7-7bc2ca6572ab

📥 Commits

Reviewing files that changed from the base of the PR and between b77536f and 210bf7d.

📒 Files selected for processing (1)
  • multi-storage-client/src/multistorageclient/utils.py

📝 Walkthrough

Walkthrough

The attribute-filter expression evaluator now preserves numeric literals as strings for equality and inequality comparisons, while ordering comparisons continue using numeric coercion.

Changes

Attribute filter comparison

Layer / File(s) Summary
Numeric literal transformation
multi-storage-client/src/multistorageclient/utils.py
AttributeFilterEvaluator.number() returns numeric tokens as strings, with comments updated to describe equality and inequality behavior.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: shunjiad

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change to numeric attribute-filter comparisons.
Description check ✅ Passed The description clearly explains the bug, the fix, and the checklist; only the task ID reference is missing.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/mr500-attribute-filter-number-equality

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

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