markburns / markburns/interactify

Fix source_location in chains

Open
#26 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

chains
Dominant language
Ruby
Stars
3
Forks
2
PR merge metrics
No merged PRs in 30d

Description

We currently have this which is I think a regression. Not the error itself, but rather the fact that it isn't reporting on the location of the `.if`, `.each`, or `.chain` call within the application, but rather still referring to the gem internals.

It would be better to have a source_location line within the application for each interactor and DSL method call that fires an interactor. run/run!/call/call!

### running rspec without `--backtrace`

```
# ./app/interactors/point_of_failure.rb:12:in `call'
# ./somewhere/in/the/app/code.rb:9:in `block (2 levels) in '
```

where `PointOfFailure` is deeply nested call after `Somewhere::In::The::App::Code.call!`

I.e. instead of running rspec with `--backtrace` and seeing the following

```
# ./app/interactors/point_of_failure.rb:12:in `call'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:143:in `block in run!'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:213:in `block in with_hooks'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:224:in `run_around_hooks'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:211:in `with_hooks'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:142:in `run!'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:27:in `block in call'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:19:in `each'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:19:in `call'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:143:in `block in run!'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:213:in `block in with_hooks'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:224:in `run_around_hooks'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:211:in `with_hooks'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:142:in `run!'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:27:in `block in call'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:19:in `each'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:19:in `call'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:143:in `block in run!'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:213:in `block in with_hooks'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:224:in `run_around_hooks'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:211:in `with_hooks'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:142:in `run!'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:76:in `call!'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/if_klass.rb:25:in `run!'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/if_klass.rb:86:in `block in attach_run!'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:76:in `call!'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/each_chain.rb:58:in `block (4 levels) in klass'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/each_chain.rb:57:in `each'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/each_chain.rb:57:in `block (3 levels) in klass'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/each_chain.rb:53:in `each'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/each_chain.rb:53:in `each_with_index'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/each_chain.rb:53:in `block (2 levels) in klass'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:27:in `block in call'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:19:in `each'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:19:in `call'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:143:in `block in run!'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:213:in `block in with_hooks'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:224:in `run_around_hooks'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:211:in `with_hooks'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:142:in `run!'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:27:in `block in call'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:19:in `each'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:19:in `call'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:143:in `block in run!'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:213:in `block in with_hooks'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:224:in `run_around_hooks'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:211:in `with_hooks'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:142:in `run!'
# /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:76:in `call!'
# ./somewhere/in/the/app/code.rb:9:in `block (2 levels) in '
```

we should see something more like (pseudocode) without `--backtrace`

```
# ./app/interactors/point_of_failure.rb:12:in `call'
# ./app/interactors/another_caller.rb:11:in `call' in '
# ./app/interactors/some_organizer.rb:11:in `call' in '
# ./somewhere/in/the/app/code.rb:11:in `block (2 levels) in '
# ./somewhere/in/the/app/code.rb:10:in `block (2 levels) in '
# ./somewhere/in/the/app/code.rb:9:in `block (2 levels) in '
```

Then have a trace as above but with DSL internal interspersed in the stack trace.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the DSL entry points named in the trace: interactify/dsl/organizer.rb, interactify/dsl/if_klass.rb, and interactify/dsl/each_chain.rb, along with the run/call paths they invoke. Reproduce the nested `.if`, `.each`, or `.chain` calls without `--backtrace`; done means the trace reports application source locations for each interactor and DSL method call while retaining the relevant internal frames.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.