Skip to content

Show correct category/error when Search Console email report fails due to Insufficient Permissions #12276

@jimmymadon

Description

@jimmymadon

Bug Description

In Issue #12110, we introduced the categorisation of errors that occur during Search Console and Analytics report generation. For Analytics, the errors thrown do correctly get categorised - however, this is not the case for Search Console when the Insufficient Permissions error occurs.

Steps to reproduce

  1. Set up Site Kit using a Search Console property.
  2. Remove the property from the Google Search Console Admin Dashboard from the logged-in user's account
  3. Hard refresh Site Kit dashboard (clear cache and/or log out and then log in).
  4. The dashboard should show Insufficient Permissions errors for Search Console widgets.
  5. Set up a weekly email for your user and use the Tester plugin to Trigger the initiator for the weekly email.
  6. Check the Email logs to see that the email has failed to send for 3 times.
  7. Now refresh the Site Kit dashboard and check the User Settings Side sheet - it shows the generic fallback error instead of the Insufficient Permissions error for Search Console.

Screenshots

Image

Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • When an email report fails due to the user having "Insufficient Permissions" for Search Console, the "Search Console Insufficient Permissions" error from the PUE Errors Spreadsheet should be rendered in the Email Reporting User Settings Side Panel.

Implementation Brief

The below IB has already been implemented in the attached PR.

  • In includes/Core/Email_Reporting/Email_Reporting_Data_Requests.php, within the collect_search_console_payloads, remove the is_wp_error() check as the errors are keyed by the name of the request.
  • In includes/Modules/Search_Console/Email_Reporting/Report_Request_Assembler.php, within the map_responses() method, after the normalize_response_result is run, check if result is a WP_Error. If it is, simply return the result (the WP_Error) as the payload.

Test Coverage

  • No new tests required.

QA Brief

  1. Set up Site Kit using a Search Console property.
  2. Remove the property from the Google Search Console Admin Dashboard from the logged-in user's account
  3. Hard refresh Site Kit dashboard (clear cache and/or log out and then log in).
  4. The dashboard should show Insufficient Permissions errors for Search Console widgets.
  5. Set up a weekly email for your user and use the Tester plugin to Trigger the initiator for the weekly email.
  6. Check the Email logs to see that the email has failed to send for 3 times.
  7. Refresh the Site Kit dashboard and check the User Settings Side sheet
  8. It should show the error for "Insufficient Permissions error for Search Console", eg:

We were unable to generate your report due to insufficient permissions in Search Console. To fix this, contact your administrator or get help. Report delivery will automatically resume once the issue is resolved.

Changelog entry

  • Show a Search Console-specific error message in Email reporting when a permissions issue is encountered.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Low priorityTeam SIssues for Squad 1Type: BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions