Giter Club home page Giter Club logo

Comments (29)

viralpraxis avatar viralpraxis commented on July 3, 2024 1

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?

from actor.

viralpraxis avatar viralpraxis commented on July 3, 2024 1

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

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

from actor.

afuno avatar afuno commented on July 3, 2024 1

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

At the moment I can only talk about those above.

from actor.

viralpraxis avatar viralpraxis commented on July 3, 2024 1

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

from actor.

afuno avatar afuno commented on July 3, 2024 1

@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.

from actor.

afuno avatar afuno commented on July 3, 2024 1

@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

from actor.

sunny avatar sunny commented on July 3, 2024 1

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? πŸ™πŸ»

from actor.

andrik avatar andrik commented on July 3, 2024 1

Hi @sunny

I tested and it worked.

Xnip2024-05-02_17-43-16

Thank you πŸ™

from actor.

afuno avatar afuno commented on July 3, 2024 1

@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?

from actor.

afuno avatar afuno commented on July 3, 2024

Okay, I understood the changes. Solution:

ServiceActor::Result.new(failure: true, error: "Some error")

from actor.

afuno avatar afuno commented on July 3, 2024

This didn't actually solve the problem. There are a huge number of tests. Some of them were resolved through the example I gave above. But most tests continue to fail, for example with comments like this:

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

These comments are accompanied by this error:

     NoMethodError:
       undefined method `empty?' for nil

from actor.

afuno avatar afuno commented on July 3, 2024

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?

This is a deep dependence.

from actor.

sunny avatar sunny commented on July 3, 2024

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

from actor.

viralpraxis avatar viralpraxis commented on July 3, 2024

@afuno Could you please run your suite against #148?

from actor.

afuno avatar afuno commented on July 3, 2024

The problems described above have been resolved. But overall the problem is not solved. Next error:

NoMethodError: undefined method `expected' for an instance of RSpec::Matchers::BuiltIn::RaiseError

from actor.

viralpraxis avatar viralpraxis commented on July 3, 2024

Could you please show some context of the error above? πŸ€”

from actor.

afuno avatar afuno commented on July 3, 2024

Could you please show some context of the error above? πŸ€”

This problem is resolved. It was about failure? and failure.

from actor.

afuno avatar afuno commented on July 3, 2024

I keep receiving a huge number of notifications like this:

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

I can't give an example of method names, but there are many of them and they are different. All of them are related to the specifics of the project.

from actor.

viralpraxis avatar viralpraxis commented on July 3, 2024

In general, if that's not a bug, that means that you are trying to invoke some method on ServiceActor::Result which was not defined as output in actor definition

from actor.

sunny avatar sunny commented on July 3, 2024

@afuno Can you share with us one example of code that triggers this warning that you find unexpected? πŸ™πŸ»

from actor.

sunny avatar sunny commented on July 3, 2024

The problems described above have been resolved.

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

from actor.

sunny avatar sunny commented on July 3, 2024

FYI 3.9.0 has been released with #153, which could be related to your issues.

from actor.

sunny avatar sunny commented on July 3, 2024

Thank you for reporting this back.

  • For #title, the warning is here to encourage you to not call the method if the output has not been defined.

    For example you could make sure the result has succeeded before calling #title on it, or you can even check if the #title method is defined.

  • For #nil? I’ll add this to the default methods on results πŸ‘πŸ»

  • For naming an input :error I’ll make sure we can allow this πŸ‘πŸ»

from actor.

sunny avatar sunny commented on July 3, 2024

@afuno I’ve fixed both :errors and #nil? issue. Can you try using the main branch and see if the only issue left on your code base are the warnings on title? πŸ™πŸ»

gem "service_actor", github: "sunny/actor", branch: "main"

from actor.

andrik avatar andrik commented on July 3, 2024

Hi @sunny

I made a simple example extracted from README with the following configuration:

Ruby: 3.3.1
Rails: 7.1.3.2
Actor: 3.9.1
Actor-Rails: 1.0
OS: MacOS Sonoma

I created a simple Actor

class GreetUser < Actor
  input :name

  def call
    "Have a wonderful day, #{name}!"
  end
end

When I try to run the Actor on Rails console I get this output
Xnip2024-05-02_15-30-16

OBS: I made a test using the main branch and the result was the same

from actor.

afuno avatar afuno commented on July 3, 2024

@sunny Hi. I checked version 3.9.1. It still contains a large number of warnings. There is something simple:

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

But there is something more complicated when passing data to the fail! method.

There are also critical cases that cause tests to fail. Here's an example:

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

NoMethodError: undefined method `include?' for nil

Or an example with error:

input :error, type: String, allow_nil: true
ArgumentError:
  input `error` overrides `ServiceActor::Result` instance method

from actor.

afuno avatar afuno commented on July 3, 2024

@sunny Can you please tell about the purpose of the latest releases and what are your plans for the future?

We have projects with a huge number of services. All these services were implemented in different styles, use wrappers, etc., which was not prohibited or limited by the Service Actor.

Over the last few releases of Service Actor, we have been experiencing problems with updating the library of various types. Now we don’t have a clear understanding of how the library should work, what is considered wrong, what has limitations, etc.

from actor.

sunny avatar sunny commented on July 3, 2024

Hi @afuno! Sorry to hear about those frustrations.

The changes that impact you come from using a slimmed down version of a Result instead of relying on Ruby’s deprecated OpenStruct. Therefore a lot of methods that you depended on don’t exist anymore and we need to bring them back in. I’m sorry about that.

Thank you for listing a few errors you are facing. I’ve noted:

  • blank? method => allowed in #162
  • nil? method => allowed in main
  • input :error => allowed in main
  • private_methods method => allowed in #162

Would you be willing to test your codebase against the add-blank-method branch to see if there are any other underlying issues? The codebases I use with actor don’t have the same gems or wrappers so I didn’t get to see the same issues come up.

gem "service_actor", github: "sunny/actor", branch: "add-blank-method"

from actor.

sunny avatar sunny commented on July 3, 2024

Thank you for testing! Released as 3.9.2.

from actor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.