Webhook Example Payload: "undefined method `articles' for nil:NilClass"

Servus Zammad!

Infos:

  • Used Zammad version: 6.3.1-121
  • Used Zammad installation type: docker-compose
  • Operating system: Ubuntun 24.04 Server LTS
  • Browser + version: Chrome on Linux but same on iPad (not browser related)

Expected behavior:

  • Show sample Webhook code

Actual behavior:

  • Internal Server Error 500, “undefined method `articles’ for nil:NilClass”
zammad-railsserver-1    | I, [2024-09-01T15:21:27.798199#1-150660]  INFO -- : Started GET "/api/v1/webhooks/preview?_=1725193643595" for 172.21.0.1 at 2024-09-01 15:21:27 +0200
zammad-railsserver-1    | I, [2024-09-01T15:21:27.804714#1-150660]  INFO -- : Processing by WebhooksController#preview as TEXT
zammad-railsserver-1    | I, [2024-09-01T15:21:27.804782#1-150660]  INFO -- :   Parameters: {"_"=>"1725193643595"}
zammad-railsserver-1    | E, [2024-09-01T15:21:27.845495#1-150660] ERROR -- : undefined method `articles' for nil:NilClass (NoMethodError)
zammad-railsserver-1    | app/controllers/webhooks_controller.rb:11:in `preview'
zammad-railsserver-1    | app/controllers/application_controller/has_download.rb:17:in `block (4 levels) in <module:HasDownload>'
zammad-railsserver-1    | app/controllers/application_controller/has_download.rb:16:in `block (3 levels) in <module:HasDownload>'
zammad-railsserver-1    | app/controllers/application_controller/has_download.rb:15:in `block (2 levels) in <module:HasDownload>'
zammad-railsserver-1    | app/controllers/application_controller/handles_transitions.rb:16:in `handle_transaction'
zammad-railsserver-1    | I, [2024-09-01T15:21:27.849229#1-150660]  INFO -- : Completed 500 Internal Server Error in 44ms (Views: 0.2ms | ActiveRecord: 25.3ms | Allocations: 8921)

Steps to reproduce the behavior:

Might be difficult to reproduce. On a new installation/deployment this did work fine. After some time it started to produce the error. Everything else is working correctly and no other errors are shown in the Log.

Might this be related to the nginx reverse proxy configuration?
I run the setup as docker-compose and have nginx + certbot on the host for SSL termination.

Anyway, as this error sounds more application specific, maybe there are some magic ruby commands which can be executed in the CLI to check the backend.

I hope that this is the only problem and not affecting the normal operation ot Zammad.

Thanks for your hints and guidance!

Cheers,
Bernhard

I do not think this has anything to do with nginx reverse proxy config, as the controller is intercepting the request. It might be due to some permission errors. Are you sure you are facing this issue with the same user? As far as my understanding goes, this error is due to the fact that the application is not able to locate at least one ticket as sample which the user has access to.

Magic ruby command which you can try with rails console:
usr=User.find_by(email: ‘email_of_user_having_issues’)
ticket_count = TicketPolicy::ReadScope.new(usr).resolve.count

ticket_count must be at least 1.
Good luck !

Thank you!
There are no tickets for that user.

This is a typical corner case which does usually not happen in the field.
So a fix is unlikely to happen/not required :slight_smile:

Have a nice day, bye!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.