Shopify / Shopify/shipit-engine

Adding custom github webhook getting "NameError: uninitialized constant Handlers"

Open
#1,084 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
1.5k
Forks
154
Avg merge
2h 26m
Merged PRs (30d)
3

Description

Hello,

Newbie Ruby developer, I am trying to add a custom github webhook listener to shipit. I have modified by environments/development.rb and added the following lines

Shipit::Webhooks.register_handler('issue_comment') do |params| puts "Webhook Calling issue_comment" end

I end up with the following error message on start

rake aborted! NameError: uninitialized constant Handlers /usr/local/bundle/gems/shipit-engine-0.31.0/app/models/shipit/webhooks.rb:6:in default_handlers'
/usr/local/bundle/gems/shipit-engine-0.31.0/app/models/shipit/webhooks.rb:18:in reset_handlers!' /usr/local/bundle/gems/shipit-engine-0.31.0/app/models/shipit/webhooks.rb:14:in handlers'
/usr/local/bundle/gems/shipit-engine-0.31.0/app/models/shipit/webhooks.rb:22:in register_handler' /var/shipit/config/environments/development.rb:65:in block in <top (required)>'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/railtie.rb:216:in instance_eval' /usr/local/bundle/gems/railties-6.0.2.1/lib/rails/railtie.rb:216:in configure'
/var/shipit/config/environments/development.rb:1:in <top (required)>' /usr/local/bundle/gems/railties-6.0.2.1/lib/rails/engine.rb:612:in block (2 levels) in class:Engine'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/engine.rb:611:in each' /usr/local/bundle/gems/railties-6.0.2.1/lib/rails/engine.rb:611:in block in class:Engine'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/initializable.rb:32:in instance_exec' /usr/local/bundle/gems/railties-6.0.2.1/lib/rails/initializable.rb:32:in run'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/initializable.rb:61:in block in run_initializers' /usr/local/bundle/gems/railties-6.0.2.1/lib/rails/initializable.rb:50:in each'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/initializable.rb:50:in tsort_each_child' /usr/local/bundle/gems/railties-6.0.2.1/lib/rails/initializable.rb:60:in run_initializers'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/application.rb:363:in initialize!' /var/shipit/config/environment.rb:5:in <top (required)>'
/usr/local/bundle/gems/railties-6.0.2.1/lib/rails/application.rb:339:in require_environment!' /usr/local/bundle/gems/railties-6.0.2.1/lib/rails/application.rb:515:in block in run_tasks_blocks'
Tasks: TOP => railties:install:migrations => db:load_config => environment
(See full trace by running task with --trace)
`
Any assistance would be greatly appreciated.

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 with app/models/shipit/webhooks.rb, especially default_handlers, reset_handlers!, handlers, and register_handler, then compare its initialization with config/environments/development.rb. Reproduce the startup failure and trace why the custom registration reaches the uninitialized Handlers constant; done means the environment initializes and the custom issue_comment handler can be registered without the NameError.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.