You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
npx stripe fixtures doesn't report the country from the billing address #1447
Hi everyone! I just raised a PR containing a fix for this issue. Here is a brief explanation of the problem and the approach taken to resolve it:
The Problem
When a fixture JSON file contains explicit null values (e.g. "country": null or "state": null under address), the CLI silently drops them instead of sending them over to the Stripe API. Because the null value is never transmitted in the payload, the API uses its own default fallbacks (such as defaulting the country to "US") instead of actively clearing those fields as the user intended.
The root cause comes from ParseMapForFormData and ParseArrayForFormData in pkg/parsers/parsers.go. When the JSON payload unmarshals null, it becomes a Go nil interface. However, calling reflect.ValueOf(nil).Kind() returns reflect.Invalid, which falls through to the default: continue switch case. This causes the field to be silently ignored and skipped during form data conversion.
The Fix
I've added explicit value == nil checks right before the reflection switch in both ParseMapForFormData and ParseArrayForFormData.
Now, when a nil object is detected, the CLI correctly emits the keyname with an empty string (e.g. shipping[address][country]=), which behaves correctly by passing an empty value over the network. The API successfully reads this and clears out the data field accordingly.
I also added a corresponding test case TestParseInterfaceWithNulls in parsers_test.go to ensure null cases always convert properly to an empty string.
Hope this helps! Let me know if any further tweaks are needed in the PR.
Activity
ChinmayBhattt commentedon Mar 19, 2026
#attempt
ChinmayBhattt commentedon Mar 19, 2026
Hi everyone! I just raised a PR containing a fix for this issue. Here is a brief explanation of the problem and the approach taken to resolve it:
The Problem
When a fixture JSON file contains explicit
nullvalues (e.g."country": nullor"state": nullunderaddress), the CLI silently drops them instead of sending them over to the Stripe API. Because thenullvalue is never transmitted in the payload, the API uses its own default fallbacks (such as defaulting the country to"US") instead of actively clearing those fields as the user intended.The root cause comes from ParseMapForFormData and ParseArrayForFormData in pkg/parsers/parsers.go. When the JSON payload unmarshals
null, it becomes a Gonilinterface. However, callingreflect.ValueOf(nil).Kind()returnsreflect.Invalid, which falls through to thedefault: continueswitch case. This causes the field to be silently ignored and skipped during form data conversion.The Fix
I've added explicit
value == nilchecks right before the reflection switch in both ParseMapForFormData and ParseArrayForFormData.Now, when a
nilobject is detected, the CLI correctly emits the keyname with an empty string (e.g.shipping[address][country]=), which behaves correctly by passing an empty value over the network. The API successfully reads this and clears out the data field accordingly.I also added a corresponding test case TestParseInterfaceWithNulls in parsers_test.go to ensure
nullcases always convert properly to an empty string.Hope this helps! Let me know if any further tweaks are needed in the PR.