• contenteffect

    (@contenteffect)


    Environment

    • Site Kit version: 1.182.0
    • WordPress: 6.9.4
    • PHP: 8.3.32

    Description

    We are seeing a weekly fatal error when the Site Kit Email Reporting cron job runs.

    Search Console is configured correctly and works normally in the Site Kit dashboard. Analytics and the other connected services also work without any issues.

    The error only occurs during the weekly Email Reporting task.

    Fatal error

    Uncaught Error: Cannot use object of type WP_Error as array
    
    Report_Request_Assembler.php:182
    

    Stack trace starts with:

    Google\Site_Kit\Modules\Search_Console\Email_Reporting\Report_Request_Assembler->map_responses()
    Google\Site_Kit\Core\Email_Reporting\Email_Reporting_Data_Requests->collect_search_console_payloads()
    

    Code analysis

    Email_Reporting_Data_Requests::collect_search_console_payloads() contains:

    $response = $module->set_data(
        'searchanalytics-batch',
        array(
            'requests' => $requests,
        )
    );
    
    return $request_assembler->map_responses( $response, $request_map );
    

    According to the PHPDoc, this method may return:

    @return array|WP_Error
    

    However, map_responses() assumes $responses is always an array and immediately accesses:

    $responses[ $identifier ]
    

    If $module->set_data() returns a WP_Error, PHP throws:

    Cannot use object of type WP_Error as array
    

    It appears that either:

    • collect_search_console_payloads() should check is_wp_error( $response ) before calling map_responses(), or
    • map_responses() should handle a WP_Error argument before treating it as an array.

    Additional information

    • Search Console data loads correctly in the dashboard.
    • Site Health reports all required scopes and permissions.
    • The issue appears when the Search Console module is managed by another connected user. searchanalytics-batch returns a WP_Error with missing_required_scopes (403), but collect_search_console_payloads() passes the WP_Error directly to map_responses(), causing a fatal error instead of handling the authorization problem gracefully.

    Please let me know if additional debug information or logs would be helpful.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Adam Dunnage

    (@adamdunnage)

    Hi there @contenteffect, thanks for opening a support topic and sharing all the information. I’d be happy to look into this further for you. If you could share some additional information then that would be helpful. Please can you share the following:

    1. Your Site Health information. You can use this form to share privately if preferred.
    2. Are the email reports delivered or are they not being sent as the result of this fatal error?

    While we investigate this further, the above information would be useful for us. If you have anything else to share or any other questions at this time then let me know and I will be happy to help.

    Plugin Support Adam Dunnage

    (@adamdunnage)

    @contenteffect I just wanted to follow up on this with you to let you know that we have opened an issue to help address this which you can follow here. Once this has been pushed out, I will reach back out to you to check if this has improved.

    Plugin Support Adam Dunnage

    (@adamdunnage)

    @contenteffect This should now be fixed in the latest version of Site Kit. Please can you confirm this to be the case?

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.