Skip to content

Send filter array operators as a single form field on POST requests (v3.30.1) - #131

Merged
cb-alish merged 4 commits into
masterfrom
fix/form-encode-filter-arrays
Aug 11, 2026
Merged

Send filter array operators as a single form field on POST requests (v3.30.1)#131
cb-alish merged 4 commits into
masterfrom
fix/form-encode-filter-arrays

Conversation

@cb-alish

@cb-alish cb-alish commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

Filter operators in, not_in and between carry 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 to encodeParams, 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.

encodeParams now handles these operators at any nesting depth, so POST matches what GET already produced. Ordinary arrays such as coupon_ids keep their index encoding.

Found while validating published code samples: export.subscriptions({ subscription: { updated_at: { between: [a, b] } } }) sent

subscription[updated_at][between][0]=1704067200&subscription[updated_at][between][1]=1717199999

and now sends

subscription[updated_at][between]=[1704067200,1717199999]

Released as v3.30.1.

Test plan

  • npm test — 105 passing
  • New regression test asserts the POST body for between and in, and that [between][0] is absent
  • Verified GET/list output is byte-identical to before
  • Verified coupon_ids and subscription_items index encoding is unchanged

Made with Cursor

Updated POST form encoding for in, not_in, and between filters. 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 version 3.30.1.

cb-alish and others added 2 commits August 11, 2026 11:19
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-io

snyk-io Bot commented Aug 11, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues
Secrets 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 35eee2e0-3ff7-4ba7-88ee-87e9235b543c

📥 Commits

Reviewing files that changed from the base of the PR and between fb45276 and ac7237c.

📒 Files selected for processing (1)
  • test/util.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/util.test.ts

Walkthrough

The POST parameter encoder now serializes in, not_in, and between arrays as single JSON-encoded fields. Tests cover subscription export filters and parameter encoding. Release metadata and the client version are updated to 3.30.1.

Changes

Filter serialization correction

Layer / File(s) Summary
Array operator serialization
src/util.ts, test/requestWrapper.test.ts, test/util.test.ts
The encoder shares the in, not_in, and between operator list with serialize. Non-empty arrays use single JSON-encoded fields, and empty arrays are omitted. Tests cover filter operators, nested parameters, GET serialization, list parameters, and export filters.
Release version alignment
VERSION, package.json, src/environment.ts, CHANGELOG.md
Release metadata and Environment.clientVersion are updated from 3.30.0 to 3.30.1. The changelog records the serialization fix.

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

🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

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>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between d990d9f and fb45276.

📒 Files selected for processing (2)
  • src/util.ts
  • test/util.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/util.ts

Comment thread test/util.test.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>
@cb-alish
cb-alish merged commit b74a74e into master Aug 11, 2026
9 checks passed
@cb-alish
cb-alish deleted the fix/form-encode-filter-arrays branch August 11, 2026 09:58
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