zulip / zulip-redmine-plugin

Redmine plugin for Zulip notifications on issue tracker changes
Apache License 2.0
12 stars 17 forks source link

Catch communication error if zulip is not available #25

Closed hi-ko closed 5 years ago

hi-ko commented 5 years ago

if for any reason zulip is not available or throws an error, an update on redmine results also in a http 500 and stops processing. This is painful since also no email notifications will be send. The plugin should handle exceptions in general but especially for communication with the zulip server.

batistadasilva commented 5 years ago

@hi-ko thank you for the feedback, this is gonna be fixed

does the plugin writes anything in logs when this kind of communication errors happen? that information would help me on solving this problem

hi-ko commented 5 years ago

@felipebatista, you should catch errors which occour in your api.rb when posting the message.

A simple test for a server which is not reachable (but you should not focus on that specific error rather then handling an error in general which may occur during post and showing the user a message in the UI)

App 1136 stderr: Started POST "/settings/plugin/redmine_zulip" for 1.2.3.4 at 2019-10-15 13:40:29 +0000
App 1136 stderr: Processing by SettingsController#plugin as HTML
App 1136 stderr:   Parameters: {"utf8"=>"✓", "authenticity_token"=>"asdasdfasdfasdfaoqwierpwoqierwqpoeriu==", "settings"=>{"zulip_url"=>"https://chat.mycompany.org", "zulip_email"=>"bot@chat.mycompany.org", "zulip_api_key"=>"qioweoqiwezoqwiru"}, "commit"=>"Apply", "id"=>"redmine_zulip"}
App 1136 stderr:   Current user: admin (id=1)
App 1136 stderr: Redirected to http://redmine.test.org/settings/plugin/redmine_zulip
App 1136 stderr: Completed 302 Found in 9ms (ActiveRecord: 2.6ms)
App 1136 stderr: Started GET "/settings/plugin/redmine_zulip" for 1.2.3.4 at 2019-10-15 13:40:29 +0000
App 1136 stderr: Processing by SettingsController#plugin as HTML
App 1136 stderr:   Parameters: {"id"=>"redmine_zulip"}
App 1136 stderr: Settings cache cleared.
App 1136 stderr:   Current user: admin (id=1)
App 1136 stderr:   Rendering settings/plugin.html.erb within layouts/admin
App 1136 stderr:   Rendered plugins/redmine_zulip/app/views/settings/_redmine_zulip.html.erb (0.3ms)
App 1136 stderr:   Rendered settings/plugin.html.erb within layouts/admin (1.5ms)
App 1136 stderr:   Rendered admin/_menu.html.erb (6.8ms)
App 1136 stderr:   Rendering layouts/base.html.erb
App 1136 stderr:   Rendered plugins/redmineup_tags/app/views/tags/_additional_assets.html.erb (0.5ms)
App 1136 stderr:   Rendered plugins/redmine_new_issue_view/app/views/new_issue_view/_header_assets.html.erb (0.2ms)
App 1136 stderr:   Rendered plugins/additionals/app/views/additionals/_html_head.html.slim (2.7ms)
App 1136 stderr:   Rendered plugins/additionals/app/views/additionals/_content.html.slim (0.2ms)
App 1136 stderr:   Rendered plugins/redmineup_tags/app/views/tags/_select2_transformation_rules.html.erb (0.2ms)
App 1136 stderr:   Rendered plugins/additionals/app/views/additionals/_body_bottom.html.slim (0.2ms)
App 1136 stderr:   Rendered layouts/base.html.erb (13.4ms)
App 1136 stderr: Completed 200 OK in 36ms (Views: 27.0ms | ActiveRecord: 3.1ms)
App 1136 stderr: Started PATCH "/issues/2" for 1.2.3.4 at 2019-10-15 13:40:36 +0000
App 1136 stderr: Processing by IssuesController#update as HTML
App 1136 stderr:   Parameters: {"utf8"=>"✓", "authenticity_token"=>"asdasdfasdfasdfaoqwierpwoqierwqpoeriu==", "form_update_triggered_by"=>"", "issue"=>{"is_private"=>"0", "tracker_id"=>"1", "subject"=>"asdfasd", "description"=>"", "status_id"=>"1", "priority_id"=>"2", "assigned_to_id"=>"", "parent_issue_id"=>"1", "start_date"=>"2019-10-15", "due_date"=>"", "estimated_hours"=>"", "done_ratio"=>"0", "tag_list"=>[""], "notes"=>"sadf", "private_notes"=>"0", "lock_version"=>"3"}, "was_default_status"=>"1", "time_entry"=>{"hours"=>"", "activity_id"=>"", "comments"=>""}, "last_journal_id"=>"3", "commit"=>"Submit", "next_issue_id"=>"1", "issue_position"=>"1", "issue_count"=>"2", "id"=>"2"}
App 1136 stderr:   Current user: admin (id=1)
App 1136 stderr: Completed 500 Internal Server Error in 77ms (ActiveRecord: 11.8ms)
App 1136 stderr:
App 1136 stderr: SocketError (Failed to open TCP connection to chat.mycompany.org:443 (getaddrinfo: No address associated with hostname)):
App 1136 stderr:
App 1136 stderr: plugins/redmine_zulip/lib/redmine_zulip/api.rb:40:in `send'
App 1136 stderr: plugins/redmine_zulip/lib/redmine_zulip/issue_patch.rb:311:in `update_issue_subject'
App 1136 stderr: app/controllers/issues_controller.rb:552:in `save_issue_with_child_records'
App 1136 stderr: app/controllers/issues_controller.rb:169:in `update'
App 1136 stderr: lib/redmine/sudo_mode.rb:63:in `sudo_mode'
batistadasilva commented 5 years ago

hello @hi-ko, please try the new unreleased versions 2.1-alpha1 or 3.1-alpha1

thank you!

hi-ko commented 5 years ago

@felipebatista working as expected, An enhancement would be to at least create a waring in the log. At the moment any error would be silently ignored/cachted. Thank you!

batistadasilva commented 5 years ago

@hi-ko, please try 3.1-beta1

hi-ko commented 5 years ago

perfect: using 437b5b2 I see e.g. Zulip API error: Failed to open TCP connection to chat.mycompany.com:443 (getaddrinfo: No address associated with hostname) in the log

good job!