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 bugsnag warning #11733

Merged
merged 5 commits into from
Nov 13, 2023

Conversation

yasirazgar
Copy link
Contributor

@yasirazgar yasirazgar commented Oct 28, 2023

What? Why?

What should we test?

  • Introduce a error deliberately. Ex. In app/views/admin/reports/_date_range_form.html.haml, update text_field to tex_field and goto http://localhost:3000/admin/reports/customers. And check the logs.

In Master: - Bugsnag warning is printed

17:22:39 rails.1   | Not notifying due to an invalid api_key
17:22:39 rails.1   |
17:22:39 rails.1   | ActionView::Template::Error (undefined method `tex_field' for #<ActionView::Helpers::FormBuilder:0x000000010ea91e88 @nested_child_index={}, @options={:allow_method_names_outside_object=>false, :skip_default_ids=>false, :html=>{:class=>"new_q", :id=>"new_q"}, :method=>:post, :local=>true}, @template=#<ActionView::Base:0x0000000004e3e0>, @object=Ransack::Search<class: Spree::Order, base: Grouping <combinator: and>>, @object_name="q", @default_options={:skip_default_ids=>false, :allow_method_names_outside_object=>false}, @default_html_options={}, @multipart=nil, @index=nil>
17:22:39 rails.1   |
17:22:39 rails.1   | ::Haml::Helpers.html_escape((( f.tex_field "#{field}_gt", :class => 'datetimepicker datepicker-from', :placeholder => t(:start), data: { controller: "flatpickr", "flatpickr-enable-time-value": true, "flatpickr-default-date-value": "startOfDay" }
17:22:39 rails.1   |                                 ^^^^^^^^^^
17:22:39 rails.1   | Did you mean?  text_field
17:22:39 rails.1   |                date_field):
17:22:39 rails.1   |     4: .row.date-range-filter
17:22:39 rails.1   |     5:   .alpha.two.columns= label_tag nil, t(:date_range)
17:22:39 rails.1   |     6:   .omega.fourteen.columns
17:22:39 rails.1   |     7:     = f.tex_field "#{field}_gt", :class => 'datetimepicker datepicker-from', :placeholder => t(:start), data: { controller: "flatpickr", "flatpickr-enable-time-value": true, "flatpickr-default-date-value": "startOfDay" }
17:22:39 rails.1   |     8:     %span.range-divider
17:22:39 rails.1   |     9:       %i.icon-arrow-right
17:22:39 rails.1   |    10:     = f.text_field "#{field}_lt", :class => 'datetimepicker datepicker-to', :placeholder => t(:stop), data: { controller: "flatpickr", "flatpickr-enable-time-value": true, "flatpickr-default-date-value": "endOfDay" }
17:22:39 rails.1   |

In feature branch: Bugsnag warning should not be printed

ActionView::Template::Error (undefined method `tex_field' for #<ActionView::Helpers::FormBuilder:0x000000010d231a28 @nested_child_index={}, @options={:allow_method_names_outside_object=>false, :skip_default_ids=>false, :html=>{:class=>"new_q", :id=>"new_q"}, :method=>:post, :local=>true}, @template=#<ActionView::Base:0x0000000004e408>, @object=Ransack::Search<class: Spree::Order, base: Grouping <combinator: and>>, @object_name="q", @default_options={:skip_default_ids=>false, :allow_method_names_outside_object=>false}, @default_html_options={}, @multipart=nil, @index=nil>
17:19:48 rails.1   |
17:19:48 rails.1   | ::Haml::Helpers.html_escape((( f.tex_field "#{field}_gt", :class => 'datetimepicker datepicker-from', :placeholder => t(:start), data: { controller: "flatpickr", "flatpickr-enable-time-value": true, "flatpickr-default-date-value": "startOfDay" }
17:19:48 rails.1   |                                 ^^^^^^^^^^
17:19:48 rails.1   | Did you mean?  text_field
17:19:48 rails.1   |                date_field):
17:19:48 rails.1   |     4: .row.date-range-filter
17:19:48 rails.1   |     5:   .alpha.two.columns= label_tag nil, t(:date_range)
17:19:48 rails.1   |     6:   .omega.fourteen.columns
17:19:48 rails.1   |     7:     = f.tex_field "#{field}_gt", :class => 'datetimepicker datepicker-from', :placeholder => t(:start), data: { controller: "flatpickr", "flatpickr-enable-time-value": true, "flatpickr-default-date-value": "startOfDay" }
17:19:48 rails.1   |     8:     %span.range-divider
17:19:48 rails.1   |     9:       %i.icon-arrow-right
17:19:48 rails.1   |    10:     = f.text_field "#{field}_lt", :class => 'datetimepicker datepicker-to', :placeholder => t(:stop), data: { controller: "flatpickr", "flatpickr-enable-time-value": true, "flatpickr-default-date-value": "endOfDay" }
17:19:48 rails.1   |

Release notes

Changelog Category (reviewers may add a label for the release notes):

  • User facing changes
  • API changes (V0, V1, DFC or Webhook)
  • Technical changes only
  • Feature toggled

The title of the pull request will be included in the release notes.

Dependencies

Documentation updates

Copy link
Member

@dacook dacook left a comment

Choose a reason for hiding this comment

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

Hi Yasir, thanks for looking into this. I'm wondering if it would work to set a random string
for the key, eg:
config.api_key = "anything"

Would you be able to try this? Then we won't need to expose the actual api key.

If so, I'm not sure if this change here is needed (it seems to do the same thing as the removed line config.notify_release_stages = %w(production staging)

@yasirazgar
Copy link
Contributor Author

No luck setting a random string as api, same warning is displayed.
Ah yes I think you are right about the notify_release_stages, I thought we need to set config.notify_release_stages to nil when we do not want to notify. I have reverted it.

@dacook
Copy link
Member

dacook commented Nov 8, 2023

Hi Yasir, thanks for your work on this. While pondering about it, I had an idea: if we don't use Bugsnag in dev, then we don't need to load the gem at all. I wasn't sure if it would work so went ahead to try it out (#11782).
It looks like it works, so I think that would be the ideal solution. Does that look right to you?

@yasirazgar
Copy link
Contributor Author

Hi @dacook, I checked your PR, I did not test it though but wouldn't this break all these place where Bugsnag is being referred in the dev env, please let me know if I am missing anything.

@dacook
Copy link
Member

dacook commented Nov 9, 2023

wouldn't this break all these place where Bugsnag is being referred in the dev env

I think you're completely right, thanks for pointing this out. So the only ways to hide the errors are:

  1. add a valid key for a bugsnag account
  2. change the log level for bugsnag (as linked in the issue)

I'd rather not add a dependency on an account, so I suggest changing the log level, would you like to do this?

@rioug rioug added the technical changes only These pull requests do not contain user facing changes and are grouped in release notes label Nov 9, 2023
@yasirazgar
Copy link
Contributor Author

@dacook Sure I can work on this in the weekend.

@yasirazgar
Copy link
Contributor Author

@dacook I have suppressed the log level for bugsnag warning in dev env, now the warning has disappeared in dev.

Copy link
Member

@mkllnk mkllnk left a comment

Choose a reason for hiding this comment

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

This is great! Just a couple if minor changes to make it excellent. 👍

config/initializers/bugsnag.rb Outdated Show resolved Hide resolved
config/initializers/bugsnag.rb Outdated Show resolved Hide resolved
Copy link
Collaborator

@rioug rioug left a comment

Choose a reason for hiding this comment

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

Good one 👍

@yasirazgar
Copy link
Contributor Author

This is great! Just a couple if minor changes to make it excellent. 👍

@mkllnk Updated as per your suggestions

@rioug
Copy link
Collaborator

rioug commented Nov 13, 2023

I just tested it, It works as expected. Merging.

@rioug rioug changed the title 11714 - Fix bugsnag warning Fix bugsnag warning Nov 13, 2023
@rioug rioug merged commit 1107083 into openfoodfoundation:master Nov 13, 2023
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
technical changes only These pull requests do not contain user facing changes and are grouped in release notes
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants