Send filter array operators as a single form field on POST requests (v3.30.1) - #131
Conversation
in/not_in/between carry the whole array in one field (updated_at[between]=[a,b]). serialize() did this for GET requests, but POST bodies go straight to encodeParams, which index-encoded the array as [between][0]/[between][1]. Nested filters on export operations were therefore silently dropped by the API. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe POST parameter encoder now serializes ChangesFilter serialization correction
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
Comment |
Covers the encoder cases beyond filters (nested resources, indexed arrays, jsonKeys, escaping) so the filter-operator behaviour is pinned against the rest of the encoder. An empty operator array is now omitted instead of being sent as an empty JSON array. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/util.test.ts`:
- Around line 196-206: The GET serialization path must omit filters whose
operators have empty arrays instead of emitting "[]". Add a regression case
alongside the existing serialize GET tests, and update serialize so the empty
operator array remains an array through encodeParams, allowing encodeParams to
omit it while preserving existing non-empty between encoding.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: 0d083888-3360-471b-bd00-3b9586ca0ea4
📒 Files selected for processing (2)
src/util.tstest/util.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/util.ts
meta_data and other json keys carry a JSON document, so an empty object is a meaningful value that clears it. Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
Filter operators
in,not_inandbetweencarry the whole array in one form field, e.g.updated_at[between]=[1704067200,1717199999].serialize()already did this for GET requests, but POST bodies go straight toencodeParams, which index-encoded the array as[between][0]/[between][1]. Nested filters on export operations were therefore ignored by the API, so an export silently returned unfiltered data.encodeParamsnow handles these operators at any nesting depth, so POST matches what GET already produced. Ordinary arrays such ascoupon_idskeep their index encoding.Found while validating published code samples:
export.subscriptions({ subscription: { updated_at: { between: [a, b] } } })sentand now sends
Released as v3.30.1.
Test plan
npm test— 105 passingbetweenandin, and that[between][0]is absentcoupon_idsandsubscription_itemsindex encoding is unchangedMade with Cursor
Updated POST form encoding for
in,not_in, andbetweenfilters. These arrays now use single JSON-encoded fields at any nesting depth. Ordinary arrays retain index encoding. Empty filter arrays are omitted. Added regression tests, including empty JSON objects, and released version3.30.1.