Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Poison 4 #2888

Merged
merged 1 commit into from
Dec 9, 2019
Merged

Add support for Poison 4 #2888

merged 1 commit into from
Dec 9, 2019

Conversation

dazuma
Copy link
Member

@dazuma dazuma commented Dec 5, 2019

Modify gax so it will run with either Poison 3 or Poison 4. Fixes #1232.

We check at compile time for Poison.Decode.decode/2 which exists in Poison 3 but was renamed to Poison.Decode.transform/2 in Poison 4, and generate different versions of the function GoogleApis.Gax.ModelBase.poison_transform/2 in response, to call the appropriate Poison function.

This also includes two Poison 4 specific fixes:

  • Poison's options are supposed to be of type Map. Most calls perform automatic conversion from Keyword, but Poison.Decode.transform doesn't. So we alter our call points accordingly.
  • Poison 4 has an apparent known issue (Duplicated call to Poison.Decoder.decode/2 when using Poison.decode/2 with %{as: struct} devinus/poison#191) where struct transformation happens twice on substructs (which causes failures because the transformation code doesn't properly handle the case when an already-transformed struct is given as input). We include a workaround to prevent the second call to transform if the input is already a struct.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Dec 5, 2019
@dazuma
Copy link
Member Author

dazuma commented Dec 5, 2019

Poison 4 requires Elixir 1.6. I have a separate PR (#2890) to update the tested Elixir versions to include 1.8 and 1.9, and remove 1.4 and 1.5.

@dazuma dazuma requested a review from chingor13 December 5, 2019 02:17
@dazuma dazuma merged commit f791dfe into googleapis:master Dec 9, 2019
@dazuma dazuma deleted the poison4 branch December 9, 2019 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

poison version 4 breaks decoding
3 participants