actor: Invoking undefined methods on `ServiceActor::Result` will lead to runtime errors in the next major release of Actor.

Hello.

After updating to version 3.8.0, a large number of project services in RSpec began to crash with this comment:

DEPRECATED: Invoking undefined methods on `ServiceActor::Result` will lead to runtime errors in the next major release of Actor.

In one of the examples, the service was mocked using allow and the expected result was indicated:

allow(MyService).to(
  receive(:result)
    .and_return(
      ServiceActor::Result.new(failure?: true, error: "Some error")
    )
)

But at the same time, when actually checking the result of the service, the following data appears:

service_result.failure?
# => false

service_result.success?
# => true

Please tell me what I’m doing wrong and what happened?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 29 (27 by maintainers)

Commits related to this issue

Most upvoted comments

@sunny Apparently the problems that were described above have indeed been resolved. Thank you. Can you please make a release so I can finalize this in projects?

Hi @sunny

I tested and it worked.

Xnip2024-05-02_17-43-16

Thank you 🙏

Thank you for the detailed report @andrik! Indeed the #methods method is used by introspection tools as well. I’ve merged #159 which should fix this. Can you try again from main, please? 🙏🏻

@sunny Thanks for adding compatibility. Apparently, release 3.9 has fixed the main problems described earlier.

However, there are still the following problems:

DEPRECATED: Invoking undefined methods on `ServiceActor::Result` will lead to runtime errors in the next major release of Actor. Invoked method: `title`
DEPRECATED: Invoking undefined methods on `ServiceActor::Result` will lead to runtime errors in the next major release of Actor. Invoked method: `nil?`

And what is most important is:

ArgumentError:
  input `error` overrides `ServiceActor::Result` instance method

Which reacts to this:

input :error, type: String, allow_nil: true

@afuno Can you share with us one example of code that triggers this warning that you find unexpected? 🙏🏻

Unfortunately, I can’t at the moment.

The problems described above have been resolved.

You can now use the newly-released v3.8.1, too.

But this does not solve the problem in total.


For now, I have fixed the 3.7 release line until better times. Unfortunately, at the moment I do not have time to understand hundreds of problems in tests.

I am guessing that those introspection methods are called by test-tooling like RSpec to build test doubles.

We’re using RSpec mocking actively but didn’t encounter any warnings. But I’m pretty sure there are many gems/tools which don’t paly nice with BasicObject, for example, awesome_print’s missing Kernel#ai breaks result introspection

@afuno Are there any other problematic methods generating warnings in your codebase?

At the moment I can only talk about those above.

I’ll open a PR soon if you don’t mind @sunny

@afuno Are there any other problematic methods generating warnings in your codebase?

In general, I think it might make sense to add these methods in ServiceActor::Result. BTW @afuno what’s the use-case for calling public_send/object_id/instance_variables on service result?