Skip to content

Commit

Permalink
Fixes #37667 - Provide meaningful error message on org/loc mismatch
Browse files Browse the repository at this point in the history
Added meaningful error message when webhook template fails to render due
to organization/location mismatch.
  • Loading branch information
adamlazik1 authored and adamruzicka committed Jul 22, 2024
1 parent 8e4185b commit 206702b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/webhook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def render_source(source, event_name, payload)
end

def rendered_payload(event_name, payload)
raise ::Foreman::Exception.new(N_("Webhook template not found while firing webhook '%s'. Possible organization/location mismatch in the webhook template?"), name) if webhook_template.nil?
webhook_template.render(variables: variables(event_name, payload))
end

Expand Down
2 changes: 2 additions & 0 deletions app/subscribers/foreman_webhooks/event_subscriber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module ForemanWebhooks
class EventSubscriber < ::Foreman::BaseSubscriber
def call(event)
::Webhook.deliver(event_name: event.name, payload: event.payload)
rescue ::Foreman::Exception => e
Rails.logger.error e.message
end
end
end

0 comments on commit 206702b

Please sign in to comment.