fix: avoid mutating DatetimeRange condition in check_datetime_range#1163
fix: avoid mutating DatetimeRange condition in check_datetime_range#1163jnMetaCode wants to merge 1 commit into
Conversation
`check_datetime_range` was modifying its `condition` parameter in-place by reassigning `condition.lt`, `condition.lte`, `condition.gt`, and `condition.gte` with timezone-aware versions. This caused unintended side effects: callers reusing the same `DatetimeRange` filter would find their `date` boundaries silently converted to `datetime` objects, and the filter object permanently altered. Use local variables instead so the original condition remains unchanged. Signed-off-by: JiangNan <[email protected]>
✅ Deploy Preview for poetic-froyo-8baba7 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis change refactors the Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Hey @jnMetaCode Thanks for pointing it out and providing a fix! I'll recreate the PR to point to |
|
closing in favour of #1169 |
|
Thanks @joein for picking this up and recreating the PR against |
Summary
check_datetime_rangeinqdrant_client/local/payload_filters.pyto avoid mutating itsconditionargument in-place.condition.lt,condition.lte,condition.gt, andcondition.gtewith timezone-aware conversions, permanently altering the caller'sDatetimeRangefilter object.Problem
When
check_datetime_rangeis called with aDatetimeRangecondition containing timezone-naivedatetimeordateboundaries, it converts them to timezone-awaredatetimeobjects directly on the condition object (lines 138-141). This has two side effects:dateobjects on the condition are silently converted todatetimeobjects, which could break downstream code that inspects the filter type.check_*) should not modify its inputs.Fix
Use local variables (
lt,lte,gt,gte) instead of reassigning attributes on theconditionobject. The comparison logic remains identical.Test plan
DatetimeRangefilter across multiplecheck_datetime_rangecalls no longer mutates the filter.