site-kit-wp: Cannot read properties of null (reading '0')

Bug Description

New report of ‘Cannot read properties of null (reading ‘0’)’ error message displayed in Site Kit. This has been reported twice previously with no user insights.

Recent topic: https://wordpress.org/support/topic/google-site-kit-configuration-problem-2/ Site Health: https://docs.google.com/forms/d/1lhjns2K7c0Ny7ME4gxTcsnYtNUtcMr8BvFpPQi23Y1E/edit#response=ACYDBNj60XTXxmiJSJuvu9ySD9P--oMGLlVuonUvlAMLdf5vFEecsgh7zQq9P81s-piSKbM

Previously closed topics: https://wordpress.org/support/topic/error-on-analytics-tab/ https://wordpress.org/support/topic/cannot-read-properties-of-null-reading-0/

Error message:

Cannot read properties of null (reading '0')

    in Stats
    in div
    in div
    in Widget
    in WithWidgetSlug(Widget)
    in ModuleOverviewWidget
    in WidgetRenderer
    in div
    in Cell
    in WidgetCellWrapper
    in div
    in Row
    in div
    in div
    in ForwardRef
    in WidgetAreaRenderer
    in div
    in WidgetContextRenderer
    in ModuleApp
    in GoogleSitekitModule
    in RestoreSnapshots
    in ErrorHandler
    in Root

Insights & Troubleshooting Checks performed

  • Health Check & Troubleshooting plugin check
  • Front end check (mixed content, minified content, combined JS)
  • Incognito mode
  • Checked users Site Health info, no identified causes
  • Additional .htaccess rules applied (no in 1 case, yes in another)
  • Uninstalled and reinstalled plugin
  • User confirmed no “Critical errors” in their Site Health status
  • Attempted setup/viewing dashboards from another device
  • Temporary disabled WAF rules at host level - including ModSecurity
  • Checked site setup and dashboard from another WordPress site on the same hosting platform
  • Reset Site Kit
  • Reset Site records (on the SK service)
  • Checked does the same occur when selecting a different Google account during OAuth setup
  • Checked setup using another WordPress administrator account
  • Reviewed error logs

Steps to reproduce

Unable to reproduce so far.

Screenshots

N/A

Additional Context


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

Acceptance criteria

Implementation Brief

Test Coverage

QA Brief

Changelog entry

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 21

Most upvoted comments

Thank you so much, @kuasha420! @jamesozzie @adamdunnage Seems like good info to add to the wiki, perhaps? I’ll close this issue out, but please do let us know if you have any other questions.

One user, who reported this error has shared the Nginx configurations they applied in order to resolve this. This user compared the difference in their Nginx block on a site that did connect successfully to that which encountered the error.

Old Ngix block configuration, which resulted in the error:

location / {
 try_files $uri $uri/ /index.php;
}
  
location /community {
 try_files  $uri $uri/ /community/index.php;
}

New Ngix block configuration, no errors:

location / {
   try_files $uri $uri/ @ee;
}
location @ee {
 rewrite ^(.*) /index.php?$1 last;
}
location /community {
  try_files  $uri $uri/ /community/index.php;
}

Update on this:

I’ve went through all the information available in this thread and was able to reproduce the issue. However, Most of the successful reproducing involved intentionally messing with server configuration in the following steps.

  1. Misconfiguring nginx server in a way that the query params are not property passed to PHP. - This is very easy to do if an user configures the server themselves following an incomplete or missleading tutorial.
  2. Limiting the maximum accepted URL length.: - The GET:report requests with all the query parameters produces large URL strings, if the server strips the URL before it’s passed to the PHP process, the error can happen. This is also likely to happen with misconfigured Nginx server.

Unfortunately, we can’t do anything in plugin site to mitigate this issue since the cause of it is server specific for most cases.

There are many ways to configure nginx server for WordPress so if an user is having this issue on a nginx server they’ve configured, we can provide them with the minimum nginx config to compare.

# cat /etc/nginx/nginx.conf

user http;
worker_processes 1;

events {
    worker_connections 1024;
}

http {
    include           mime.types;
    default_type      application/octet-stream;
    sendfile          on;
    keepalive_timeout 65;
    gzip              on;

    server {
        # IP, SERVER NAME. ROOT ETC GOES HERE

        # This part is important
        location / {
            try_files $uri $uri/ /index.php$is_args$args;
        }

        # Or, for sites on subdirectory
        # location /wordpress {
        #     try_files $uri $uri/ /wordpress/index.php$is_args$args;
        # }
        
        # Handle PHP files with php-fpm
        location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass            unix:/run/php-fpm7/php-fpm.sock;
            fastcgi_index           index.php;
            include                 fastcgi.conf;
        }
    }
}

Other than this, since SearchConsoleStats is known to cause this error, we can explore putting an error boundary around it. I’ll file a issue for it.

Cheers.

cc @jamesozzie @aaemnnosttv @bethanylang

To close the loop here, @eugene-manuilov did not find anything obvious in the user-provided nginx config file, so we’ve let them know that this is likely a hosting issue but it will require deeper troubleshooting from a developer as it’s not Site Kit-specific support.

Keeping this issue open for now for investigation of any future reports.