Skip to content

Send filter array operators as a single form field in URLFormEncoder (v4.25.1) - #139

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

Send filter array operators as a single form field in URLFormEncoder (v4.25.1)#139
cb-alish merged 3 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]. Only ListParamEncoder did this, and it keys off nesting level, so filters on export operations were index-encoded as [between][0]/[between][1] and ignored by the API — an export silently returned unfiltered data.

URLFormEncoder now handles these operators at any nesting depth. Ordinary arrays such as coupon_ids keep their index encoding.

Found while validating published code samples: $chargebee->export()->ramps(["ramp" => ["effective_from" => ["between" => [a, b]]]]) sent

ramp[effective_from][between][0]=1704067200&ramp[effective_from][between][1]=1717199999

and now sends

ramp[effective_from][between]=[1704067200,1717199999]

Released as v4.25.1.

Test plan

  • vendor/bin/phpunit — 62 passing
  • Two new tests cover nested (ramp[effective_from][between]) and top-level (updated_at[between]) operators
  • phpstan clean on src/ValueObjects/Encoders
  • Existing "array of primitives" and "array of sub-resources" expectations unchanged

Made with Cursor

Updated URLFormEncoder to JSON-encode non-empty in, not_in, and between filter arrays as single fields at any nesting depth. Empty filter arrays are omitted. Added nested and top-level tests. Preserved ordinary array encoding and released version 4.25.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]). Only ListParamEncoder did this, and it keys
off nesting level, so filters on export operations were index-encoded as
[between][0]/[between][1] and 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)
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: 34a64019-2dbd-4f7a-8c75-457fc97cc807

📥 Commits

Reviewing files that changed from the base of the PR and between 23ecd06 and 5a6b0a2.

📒 Files selected for processing (2)
  • src/ValueObjects/Encoders/URLFormEncoder.php
  • tests/ValueObjects/Encoder/URLFormEncoderTest.php
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/ValueObjects/Encoder/URLFormEncoderTest.php
  • src/ValueObjects/Encoders/URLFormEncoder.php

Walkthrough

URLFormEncoder now preserves selected filter operator arrays as JSON-encoded form values at nested and top-level paths. Tests cover non-empty and empty arrays. The project version and changelog are updated to 4.25.1.

Changes

Filter array encoding

Layer / File(s) Summary
Preserve filter operator arrays
src/ValueObjects/Encoders/URLFormEncoder.php, tests/ValueObjects/Encoder/URLFormEncoderTest.php
The encoder handles in, not_in, and between arrays as single JSON-encoded fields. Tests cover nested filters, top-level updated_at[between], and empty arrays.
Publish version 4.25.1
VERSION, src/Version.php, CHANGELOG.md
The project version and public version constant change to 4.25.1. The changelog records the encoding 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.

@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 `@src/ValueObjects/Encoders/URLFormEncoder.php`:
- Around line 42-45: Restrict the special JSON encoding in URLFormEncoder’s
array-handling branch to explicit filter context or an opt-in, rather than any
array key named in, not_in, or between. Preserve recursive indexed encoding for
nested non-filter arrays such as metadata[in], while keeping the existing
compact filter representation when the caller explicitly marks the value as a
filter.
🪄 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: 21711957-2331-49e0-9223-829d90253624

📥 Commits

Reviewing files that changed from the base of the PR and between 2435ca6 and 23ecd06.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • VERSION
  • src/ValueObjects/Encoders/URLFormEncoder.php
  • src/Version.php
  • tests/ValueObjects/Encoder/URLFormEncoderTest.php

Comment thread src/ValueObjects/Encoders/URLFormEncoder.php Outdated
An empty in/not_in/between array is now omitted instead of being sent as
an empty JSON array.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cb-alish
cb-alish merged commit f6e16cf into master Aug 11, 2026
4 checks passed
@cb-alish
cb-alish deleted the fix/form-encode-filter-arrays branch August 11, 2026 10:04
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