Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: bring back json marshal support for ftl.Option (#1448)
We used to support ftl.Option in normal json decoding, but was removed here in this PR: [feat: Handle sum types in backend encoder (](76ae43c) Now the issue is this use case that PFI has: They make external API requests and unmarshal the responses into ftl types, like this one: ``` type RecipientAddressResponse struct { ID uuid.UUID `json:"id"` Chain Chain `json:"chain"` Address string `json:"address"` Description string `json:"description"` AddressTag ftl.Option[string] `json:"addressTag,omitempty"` Currency ftl.Option[Currency] `json:"currency"` Status BizRecipientAddressStatus `json:"status"` } ``` Which means after upgrading ftl a lot of their tests start failing: ``` === RUN TestListAllRecipientAddresses/good /Users/mtoohey/Code/pfi/backend/modules/moneymovements/circle/circle_test.go:97: Unexpected error: failed to unmarshal response body: json: cannot unmarshal string into Go struct field RecipientAddressResponse.data.currency of type ftl.Option[ftl/moneymovements/circle.Currency] failed to unmarshal response body: json: cannot unmarshal string into Go struct field RecipientAddressResponse.data.currency of type ftl.Option[ftl/moneymovements/circle.Currency] --- FAIL: TestListAllRecipientAddresses (0.30s) --- FAIL: TestListAllRecipientAddresses/good (0.29s) ``` I'm a bit confused about all the different marshalling cases we need to support now and whether this is the right fix... With this PR, pfi's tests all work again
- Loading branch information