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

Recent versions of Oj (3.11.4 and 3.11.5) are causing issues with the Pact library #240

Closed
iamvery opened this issue Apr 27, 2021 · 7 comments

Comments

@iamvery
Copy link
Contributor

iamvery commented Apr 27, 2021

👋 I'll say up front that this was difficult to narrow down, and I'm still not certain of the root cause. It's unclear to me whether it's ultimately on the Oj or Pact side.

Problem

After updating to Oj 3.11.4 and 3.11.5, we are seeing intermittent test failures for Pact examples. The failures appear to be a result of how objects are serialized. On oj 3.11.3, responses present like:

{ "some_field" => #<Pact::SomethingLike...> }

But after upgrading certain responses later in test runs present like:

{ "some_field" => { "json_class" => "Pact::SomethingLike", ... }

Note: the issue is currently presenting itself for certain RSpec "seeds" and often happens after some successfully and correctly serialized response bodies. For example, the first Pact test will run correctly and successfully and a subsequent one is serialized incorrectly as shown above which results in failure.

Thank you for your work on this library, and please let me know if I can provide more information. Unfortunately at this time, I'm not certain how to reproduce the issue outside of our code and test suite, but I'm hopefully the reporting it may trigger some thought on recent changes.

» ruby -v
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]
» rails -v
Rails 6.1.3.1

See also ohler55/oj#656

@zorab47
Copy link

zorab47 commented Apr 28, 2021

Possibly related to this previous issue: #166

@bethesque
Copy link
Member

Thanks for the details. Until you can reproduce it reliably in a codebase you can share with me, I don't think there's much I can do to fix it unfortunately. My gut feeling based on the previous issues people have had, that you've already found, is that there will be a specific OJ setting that needs to be set to fix this.

@iamvery
Copy link
Contributor Author

iamvery commented Jul 23, 2021

I tried removing our lock on Oj and running things again, and it appears that something in a recent release has fixed the issue.

@iamvery iamvery closed this as completed Jul 23, 2021
@iamvery
Copy link
Contributor Author

iamvery commented Jul 23, 2021

I spoke too soon. The failures are order dependent so a passing build gave me false confidence 😞

@iamvery iamvery reopened this Jul 23, 2021
@iamvery
Copy link
Contributor Author

iamvery commented Jul 23, 2021

For reference, a script to reproduce this is available here: https://gist.github.com/zorab47/f00e4ad8d5b02b583c2ba97db6011f67

@bethesque
Copy link
Member

I'll have another look at it on my next OSS day.

@YOU54F
Copy link
Member

YOU54F commented Aug 15, 2024

Thanks everyone for all the investigations and the excellent reproducer!

This is now resolved as per comments here

ohler55/oj#656 (comment)

the original example has been updated.

tl;dr - if you use OJ, set Oj.default_options = { create_additions: true }

@YOU54F YOU54F closed this as completed Aug 15, 2024
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

No branches or pull requests

4 participants