fix(go): form-encode filter operator arrays as a single field - #109
Merged
Conversation
The v3 util.go template index-encodes array-valued filter operators, so updated_at[between] goes out as [between][0]/[between][1], which the API rejects with param_wrong_value. It also drops the parent prefix when recursing into a nested array, losing the sub-resource path. chargebee-go fixed this in v3.52.1 (chargebee/chargebee-go#87), but any regen overwrites util.go and brings the bug back — the sample validator has been failing on export_subscription_ramps for exactly that reason. Port the same patch here so generated SDKs keep it. 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)
WalkthroughThe Go template now serializes ChangesGo array operator serialization
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
Comment |
cb-muthiahm
approved these changes
Aug 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
templates/go/v3/util.go.hbsindex-encodes array-valued filter operators, soupdated_at[between]is sent as[between][0]/[between][1]— which the API rejects withparam_wrong_value. The same branch also drops the parent prefix when recursing into a nested array, losing the sub-resource path.chargebee-gofixed this in v3.52.1 (chargebee/chargebee-go#87), but the fix lives inutil.go, which this template overwrites on every regen — so the bug comes straight back. The sample validator has kept failing onexport_subscription_rampswithMissing required form field: ramp[effective_from][between]for exactly that reason, while go-v4 (which has no serializer template) passes. This ports the released patch so generated SDKs keep it.Node, PHP and go-v4 need no equivalent change: their serializers exist only in the SDK repos, so those fixes already survive regen.
Test plan
chargebee_sdk_spec.jsonwith this template ontochargebee-go@v3, then ran the SDK's own suite:go test ./tests/...passes, including theSerializeParamsregression cases forbetweenand for arrays nested in a sub-resource.export_subscription_rampssample against a local echo server with that SDK: it sendsramp[effective_from][between]=["1704067200","1717199999"]as a single field, which is what the validator expects (it compares array elements as strings).util.gois byte-identical to the released v3.52.1util.gothrough the serializer section.Made with Cursor
Updated the Go v3 utility template to JSON-encode non-empty
in,not_in, andbetweenarrays as single form fields. Preserved prefixes for nested arrays, omitted empty filters, and added serialization error handling. This prevents regeneration from reintroducing the filter encoding defect.