Skip to content

fix(go): form-encode filter operator arrays as a single field - #109

Merged
cb-alish merged 1 commit into
mainfrom
fix/go-v3-form-encode-filter-arrays
Aug 12, 2026
Merged

fix(go): form-encode filter operator arrays as a single field#109
cb-alish merged 1 commit into
mainfrom
fix/go-v3-form-encode-filter-arrays

Conversation

@cb-alish

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

Copy link
Copy Markdown
Contributor

Summary

templates/go/v3/util.go.hbs index-encodes array-valued filter operators, so updated_at[between] is sent as [between][0] / [between][1] — which the API rejects with param_wrong_value. The same branch 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 the fix lives in util.go, which this template overwrites on every regen — so the bug comes straight back. The sample validator has kept failing on export_subscription_ramps with Missing 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

  • Regenerated the go v3 SDK from chargebee_sdk_spec.json with this template onto chargebee-go@v3, then ran the SDK's own suite: go test ./tests/... passes, including the SerializeParams regression cases for between and for arrays nested in a sub-resource.
  • Ran the generated export_subscription_ramps sample against a local echo server with that SDK: it sends ramp[effective_from][between]=["1704067200","1717199999"] as a single field, which is what the validator expects (it compares array elements as strings).
  • Confirmed the regenerated util.go is byte-identical to the released v3.52.1 util.go through the serializer section.

Made with Cursor

Updated the Go v3 utility template to JSON-encode non-empty in, not_in, and between arrays 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.

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-io

snyk-io Bot commented Aug 12, 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 12, 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: 05c0a60b-0810-431f-a579-a0978ebd3382

📥 Commits

Reviewing files that changed from the base of the PR and between e335505 and 660dd28.

📒 Files selected for processing (1)
  • src/main/resources/templates/go/v3/util.go.hbs

Walkthrough

The Go template now serializes in, not_in, and between arrays as JSON fields. It omits empty operator filters, preserves indexed serialization for other arrays, and logs JSON serialization errors.

Changes

Go array operator serialization

Layer / File(s) Summary
Operator serialization and map parsing
src/main/resources/templates/go/v3/util.go.hbs
The template recognizes in, not_in, and between. It serializes non-empty values as JSON string arrays, omits empty filters, and retains indexed handling for other arrays. Serialization errors are logged and return an empty string.

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.

@cb-alish
cb-alish merged commit 4939173 into main Aug 12, 2026
5 of 6 checks passed
@cb-alish
cb-alish deleted the fix/go-v3-form-encode-filter-arrays branch August 12, 2026 06:56
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