Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #37667 - Provide meaningful error message on org/loc mismatch #78

Merged

Conversation

adamlazik1
Copy link
Contributor

Added meaningful error message when webhook template fails to render due to organization/location mismatch.

Copy link
Contributor

@adamruzicka adamruzicka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're running into this weird mismatch where webhooks are globally visible, but webhook templates are scoped into organizations and locations. This approach tips the scales towards the latter and treats this mismatch as an error state. An alternative could be to treat this as an expected state and silently do nothing instead of failing. Or we could lean more into global visibility point of view and disregard the template scoping.

@ofedoren opinions?

app/models/webhook.rb Outdated Show resolved Hide resolved
@@ -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 => exception
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this, the stack trace appears in the logs. I don't think the stack trace is necessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No strong opinion on this one, both ways are OK to me in this case.

@adamlazik1
Copy link
Contributor Author

We're running into this weird mismatch where webhooks are globally visible, but webhook templates are scoped into organizations and locations. This approach tips the scales towards the latter and treats this mismatch as an error state. An alternative could be to treat this as an expected state and silently do nothing instead of failing. Or we could lean more into global visibility point of view and disregard the template scoping.

@ofedoren opinions?

In my opinion, providing an error message hinting on why the webhook failed to fire is much better than saying nothing and then users wondering what happened to their webhooks.

@adamruzicka
Copy link
Contributor

Also 👮

Copy link
Member

@ofedoren ofedoren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ofedoren opinions?

It would certainly be more user friendly if we'd have unified scoping around webhooks and their templates. We could either introduce scoping for webhooks (that'd be another hot week within taxonomies' hell and will certainly introduce bugs or misbehaving, which I'd like to avoid unless necessary) or drop scoping from the templates. Not sure what it brings in terms of downsides, but if we'll unify, I'd vote for dropping.

But, the issue description is not about the idea of scoping, but more of adequate error propagation, which this PR solves well, let's stick with simplicity.

app/models/webhook.rb Outdated Show resolved Hide resolved
@@ -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 => exception
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No strong opinion on this one, both ways are OK to me in this case.

Added meaningful error message when webhook template fails to render due
to organization/location mismatch.
Copy link
Member

@ofedoren ofedoren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @adamlazik1, LGTM :)

@adamruzicka, any concerns?

@adamruzicka
Copy link
Contributor

[test Redmine issues]

Copy link
Contributor

@adamruzicka adamruzicka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I corrected the project in redmine, let's get this in

@adamruzicka adamruzicka merged commit 206702b into theforeman:master Jul 22, 2024
22 of 23 checks passed
@adamruzicka
Copy link
Contributor

Thank you @adamlazik1 & @ofedoren !

@adamlazik1 adamlazik1 deleted the fix-37667-fix-error-message branch July 22, 2024 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants