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 Sentry error "undefined method `any?' for nil" #3549

Merged
merged 1 commit into from
Feb 6, 2025

Conversation

unoduetre
Copy link
Contributor

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

Follow these steps if you are doing a Rails upgrade.

Routes in this application are being migrated to another application, please check with #govuk-patterns-and-pages when making changes.

What

This PR fixes a Sentry error

Why

In preparation for Rails 8 migration, we are checking for the Sentry errors in order to discover any regressions. It turned out this error is not related to the upgrade, but it's easy to fix, so this PR was created.

@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3549 February 6, 2025 13:42 Inactive
@unoduetre unoduetre marked this pull request as ready for review February 6, 2025 13:45
@@ -115,7 +115,7 @@
padding: true
} %>

<% if @content_item.corporate_information_pages.any? %>
<% if @content_item.corporate_information_pages&.any? %>
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe .present? is more readable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@unoduetre unoduetre force-pushed the fix-sentry-error-undefined-method-any-for-nil branch from dbb660d to 18eafd4 Compare February 6, 2025 14:11
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3549 February 6, 2025 14:11 Inactive
@@ -115,7 +115,7 @@
padding: true
} %>

<% if @content_item.corporate_information_pages.any? %>
<% if @content_item.corporate_information_pages&.present? %>
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, you don't need the & anymore!

I always use this random old blog post:

Screenshot 2025-02-06 at 14 34 08

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I somehow missed that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

ActionView::Template::Error

undefined method `any?' for nil (ActionView::Template::Error)

NoMethodError

undefined method `any?' for nil (NoMethodError)

https://govuk.sentry.io/issues/5249728298/
@unoduetre unoduetre force-pushed the fix-sentry-error-undefined-method-any-for-nil branch from 18eafd4 to 9caaf34 Compare February 6, 2025 14:56
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3549 February 6, 2025 14:56 Inactive
Copy link
Contributor

@hannako hannako left a comment

Choose a reason for hiding this comment

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

LGTM

@unoduetre unoduetre merged commit 85ede52 into main Feb 6, 2025
11 checks passed
@unoduetre unoduetre deleted the fix-sentry-error-undefined-method-any-for-nil branch February 6, 2025 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants