anteo / redmine_custom_workflows

Allows to create custom workflows for Redmine
http://www.redmine.org/plugins/custom-workflows
GNU General Public License v2.0
182 stars 72 forks source link

Uninitialized constant CustomWorkflow::WorkflowError #261

Closed andreav closed 2 years ago

andreav commented 2 years ago

Hello, I'm using this plugin on Redmine 5.x.

When a custom workflow of mine fails, I got an Internal Server Error and from logs I see this error:

 I, [2022-05-28T15:49:51.444218 #1]  INFO -- : == Running after_save custom workflow "SyncRed_SyncAttach_ObserveIssueAttach_Update"
 I, [2022-05-28T15:50:13.433552 #1]  INFO -- : Completed 500 Internal Server Error in 22306ms (ActiveRecord: 67.3ms | Allocations: 48618)
 F, [2022-05-28T15:50:13.447620 #1] FATAL -- :
 NameError (uninitialized constant CustomWorkflow::WorkflowError

   rescue WorkflowError => e
          ^^^^^^^^^^^^^
 Did you mean?  WorkflowRule):

 plugins/redmine_custom_workflows/app/models/custom_workflow.rb:97:in `rescue in run'
 plugins/redmine_custom_workflows/app/models/custom_workflow.rb:92:in `run'
 plugins/redmine_custom_workflows/app/models/custom_workflow.rb:82:in `block in run_custom_workflows'
 plugins/redmine_custom_workflows/app/models/custom_workflow.rb:81:in `run_custom_workflows'
 plugins/redmine_custom_workflows/lib/redmine_custom_workflows/patches/issue_patch.rb:76:in `after_save_custom_workflows'       
 app/models/issue.rb:228:in `create_or_update'
 app/controllers/issues_controller.rb:661:in `block in save_issue_with_child_records'
 app/controllers/issues_controller.rb:642:in `save_issue_with_child_records'
 app/controllers/issues_controller.rb:197:in `update'
 lib/redmine/sudo_mode.rb:61:in `sudo_mode'

Hope this helps. Thanks for the greatest redmine plugin ever!

picman commented 2 years ago

Hm, it is related to new Zeitwerk rules. You will have to use RedmineCustomWorkflows::Errors::WorkflowError instead of just WorkflowError.

andreav commented 2 years ago

Thank you. I can confirm it now works.

Do you need a pull request?

picman commented 2 years ago

Super. No, I've only amended the README.

andreav commented 2 years ago

Sorry, maybe I was not clear, but I had to manually modify app\models\custom_workflow.rb at row 97 and 113 by replacing WorkflowError with RedmineCustomWorkflows::Errors::WorkflowError as you suggested in order to make it work.

picman commented 2 years ago

Aha, sorry. So a pull request, please.

picman commented 2 years ago

@andreav: And the pull request?

andreav commented 2 years ago

Sorry, I immedeately pushed the fix but forgot to create the pull request. Now you should see it.