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

Fix notification missing substituted values, log deprecation if other places do this #20978

Merged

Conversation

jrafanie
Copy link
Member

# 1. Deprecate now
# 2. Fail validation going forward via errors.add(error_args)
error_args = [:options, "text bindings for notification_type: '#{notification_type.name}' failed with error: '#{e.message}' with options: '#{options.inspect}' and message #{notification_type.message.inspect}. Next release will not allow a notification without complete bindings."]
ActiveSupport::Deprecation.warn("#{error_args.join(' ')}", caller_locations[1..-1].reject {|location| location.label.include?("emit_for_event")})
Copy link
Member Author

Choose a reason for hiding this comment

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

Note, emit_for_event above is the primary caller where notifications get created indirectly if the event has a matching notification_type when you raise an event so we have to skip it as a possible caller since that's not where you need to fix the code to provide a complete event, including the full_data containing the values to substitute. It's complicated, but that's how it works currently.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would vote to put some sort of comment in the code directly about it then so the reasoning isn't lost to time.

Fixes ManageIQ#20977

Fixes warnings of the variety:

DEPRECATION WARNING: options text bindings for notification_type: automate_service_provisioned failed with error: 'key{subject} not found' with options: '{}' and message "Service %{subject} has been provisioned.". Next release will not allow a notification without complete bindings. (called from block (3 levels) in <top (required)> at /Users/joerafaniello/Code/manageiq/spec/models/notification_spec.rb:14)
DEPRECATION WARNING: options text bindings for notification_type: automate_service_provisioned failed with error: 'key{subject} not found' with options: '{}' and message "Service %{subject} has been provisioned.". Next release will not allow a notification without complete bindings. (called from block (3 levels) in <top (required)> at /Users/joerafaniello/Code/manageiq/spec/models/notification_spec.rb:15)
DEPRECATION WARNING: options text bindings for notification_type: service_retired failed with error: 'key{subject} not found' with options: '{}' and message "Service %{subject} has been retired.". Next release will not allow a notification without complete bindings. (called from block (3 levels) in <top (required)> at /Users/joerafaniello/Code/manageiq/spec/models/notification_spec.rb:16)
DEPRECATION WARNING: options text bindings for notification_type: automate_tenant_info failed with error: 'key{message} not found' with options: '{}' and message "%{message}". Next release will not allow a notification without complete bindings. (called from block (5 levels) in <top (required)> at /Users/joerafaniello/Code/manageiq/spec/models/notification_spec.rb:98)
@jrafanie jrafanie force-pushed the fix_notification_missing_substituted_values branch from 5fecc07 to 8e87dc4 Compare January 21, 2021 18:09
@miq-bot
Copy link
Member

miq-bot commented Jan 21, 2021

Checked commits jrafanie/manageiq@62847b3~...8e87dc4 with ruby 2.6.3, rubocop 0.82.0, haml-lint 0.35.0, and yamllint
3 files checked, 1 offense detected

app/models/notification.rb

@Fryguy Fryguy merged commit cac4c50 into ManageIQ:master Jan 21, 2021
@jrafanie jrafanie deleted the fix_notification_missing_substituted_values branch January 21, 2021 21:20
simaishi pushed a commit that referenced this pull request Jan 29, 2021
…tituted_values

Fix notification missing substituted values, log deprecation if other places do this

(cherry picked from commit cac4c50)
@simaishi
Copy link
Contributor

Kasparov backport details:

$ git log -1
commit e2fd3c7f2a258f5ce5f5e5a275b3a6c2c1e71687
Author: Jason Frey <fryguy9@gmail.com>
Date:   Thu Jan 21 14:47:25 2021 -0500

    Merge pull request #20978 from jrafanie/fix_notification_missing_substituted_values

    Fix notification missing substituted values, log deprecation if other places do this

    (cherry picked from commit cac4c5044bfed98ba18307c98f2bd59e901186bc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants