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

Issues with stripity_stripe after 1.10.0 #89

Open
hgezim opened this issue Jan 10, 2025 · 3 comments
Open

Issues with stripity_stripe after 1.10.0 #89

hgezim opened this issue Jan 10, 2025 · 3 comments
Labels

Comments

@hgezim
Copy link

hgezim commented Jan 10, 2025

    ** (exit) exited in: GenServer.call(Mimic.Server, {:expect, {Stripe.Subscription, :retrieve, #Function<9.83210849/1 in Phapi.AccountsTest."test subscriptions handle_subscription_action/2 handles stripe error gracefully"/1>, 1}, 1, #PID<0.581.0>}, 60000)
         ** (EXIT) an exception was raised:
             ** (KeyError) key :required not found in: %{default: nil, field: :id}
                 (mimic 1.10.1) lib/mimic/module.ex:128: anonymous fn/1 in Mimic.Module.generate_mimic_struct/1
                 (elixir 1.18.1) lib/enum.ex:2354: anonymous fn/3 in Enum.split_with/2
                 (elixir 1.18.1) lib/enum.ex:2546: Enum."-split_with/2-lists^foldl/2-1-"/3
                 (elixir 1.18.1) lib/enum.ex:2546: Enum.split_with/2
                 (mimic 1.10.1) lib/mimic/module.ex:128: Mimic.Module.generate_mimic_struct/1
                 (mimic 1.10.1) lib/mimic/module.ex:118: Mimic.Module.create_mock/2
                 (mimic 1.10.1) lib/mimic/module.ex:37: Mimic.Module.replace!/2
                 (mimic 1.10.1) lib/mimic/server.ex:522: Mimic.Server.ensure_module_copied/2
                 (mimic 1.10.1) lib/mimic/server.ex:363: Mimic.Server.handle_call/3
                 (stdlib 6.2) gen_server.erl:2381: :gen_server.try_handle_call/4
                 (stdlib 6.2) gen_server.erl:2410: :gen_server.handle_msg/6
                 (stdlib 6.2) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
     code: Mimic.expect(Stripe.Subscription, :retrieve, fn _ ->
     stacktrace:
       (elixir 1.18.1) lib/gen_server.ex:1128: GenServer.call/3
       (mimic 1.10.1) lib/mimic.ex:235: Mimic.expect/4
       test/phapi/accounts_test.exs:332: (test)

That's the first one then the rest show up as:

 2) test send_welcome_email/2 successfully sends welcome email (Phapi.AccountsTest)
     test/phapi/accounts_test.exs:548
     ** (ArgumentError) Module Phapi.Emails.AuthMailer has not been copied. See docs for Mimic.copy/1
     code: Mimic.expect(Phapi.Emails.AuthMailer, :deliver_welcome_email, fn _user, url ->
     stacktrace:
       (mimic 1.10.1) lib/mimic.ex:546: Mimic.validate_server_response/2
       test/phapi/accounts_test.exs:549: (test)

Totally mimic copied tho.

Downgrading to 1.10.0 seem to fix this.

Sorry for such a crappy bug report.

@edgurgel edgurgel added the bug label Jan 11, 2025
@edgurgel
Copy link
Owner

edgurgel commented Jan 11, 2025

Thanks that's not a crappy bug report!

Could you please provide which elixir version are you using?

Just saw on the stacktrace that's 1.18.1

@edgurgel
Copy link
Owner

@hgezim I've just quickly tried with Elixir 1.18.1, latest Mimic and got no errors 🤔 Could you provide a minimal repo that I can use that reproduces the error or something like this?

@jeroenbourgois
Copy link

jeroenbourgois commented Feb 4, 2025

FYI we are having the same issue, but only on 1.18.1 and only in CI. When I run tests on my local machine it works with both 1.18.1 and 1.18.2

Maybe it is something in combination with the erlang/OTP version.

Downgrading to 1.10.0 also fixed the issue, but on 1.10.2 I got the same errors. My guess is the default struct change is somehow related to this issue. 7a039df

I would like to help out but again, I can only reproduce this on our CI machine, not on my local machine; for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants