This has me mystified - reports stopped working, watchdog contains:

Code: 400 - Error: Bad Request - Message: GDatainvalidParameterfiltersInvalid value ''. Values must match the following regular expression: 'ga:.+'

Previously the module was working fine, and I don't *think* I've changed anything. Any ideas?

Comments

jakemac53’s picture

I have the same error occurring, only happens on one account though which is really weird (I am running reports on well over 50 that all work fine).

netgenius.co.uk’s picture

Maybe it's a problem at the Google end? That message must be coming back from their web-service. Configuration of GA maybe, although my GA reports via the GA web-interface all seem fine.

GreenReaper’s picture

Google is no longer accepting empty parameters, because they do not match the above regular expression. In particular, 'filters' and/or 'segment' are liable to be NULL, which results in a params array like this:

	Array (
  [ids] => ga:12345678
  [dimensions] => ga:date
  [metrics] => ga:visits
  [sort] => ga:date
  [start-date] => 2012-06-11
  [end-date] => 2012-07-11
  [filters] =>
  [segment] =>
  [start-index] => 1
  [max-results] => 10000
  [v] => 2
) 

.

Modifying function queryReportFeed in GAFeed.lib.inc to avoid including them if they are NULL resolves this situation:

/* Accept only strings, not arrays, for the following parameters */
if (isset($params['filters'])) $parameters['filters'] = $params['filters'];
if (isset($params['segment'])) $parameters['segment'] = $params['segment'];
if (isset($params['start_index'])) $parameters['start-index'] = $params['start_index'];
if (isset($params['max_results'])) $parameters['max-results'] = $params['max_results'];

I probably didn't need to change the last two, as they are set by default, but might as well be consistent.

The parameter 'dimensions' is also of the ga: form but is checked for null higher in the function, and not added if it is NULL. Similarly, 'sort_metric' will not be used if 'metrics' is set (which it is by default). 'start_date' and 'end_date' may be set to NULL but will not be checked against this regular expression.

GreenReaper’s picture

Category: support » bug
Priority: Normal » Critical

Changing this to a critical bug as the module is unusuable in the current state for most use cases.

biblos’s picture

I have the same problem:

Code: 400 - Error: Bad Request - Message: GDatainvalidParameterfiltersInvalid value ''. Values must match the following regular expression: 'ga:.+'

.. and afraid that's not the issue of the module, but most likely - the GAPI.

If you try module (no changes in code) with other domain within the same GA account, it will work fine.

wanjee’s picture

[Removed my message because it added confusion and nothing else.]

rsjaffe’s picture

Getting the same error as others in this thread.

Commenting the line 'segment' => NULL, didn't help.

wanjee’s picture

Problem disappeared after implementation of #3 solution.

introfini’s picture

#3 also worked for me.

Thank you GreenReaper!

rsjaffe’s picture

#3 worked for me--using version 7.x of the module.

ScottBaetz’s picture

Another success when adopting #3... Please deploy an update, so we may update all sites.

Jawi’s picture

#3 worked for me

Dillibabu’s picture

#3 worked for me. Thanks. changed code GAFeed.lib.inc file line #344

Previous code :

/* Accept only strings, not arrays, for the following parameters */
   $parameters['filters'] = $params['filters'];
    $parameters['segment'] = $params['segment'];
    $parameters['start-index'] = $params['start_index'];
    $parameters['max-results'] = $params['max_results'];

Changed code :

/* Accept only strings, not arrays, for the following parameters */
if (isset($params['filters'])) $parameters['filters'] = $params['filters'];
if (isset($params['segment'])) $parameters['segment'] = $params['segment'];
if (isset($params['start_index'])) $parameters['start-index'] = $params['start_index'];
if (isset($params['max_results'])) $parameters['max-results'] = $params['max_results'];
grendzy’s picture

Version: 6.x-1.1 » 7.x-3.x-dev
Assigned: Unassigned » grendzy
Status: Active » Needs work

This just appeared on our site too. Maybe Google made a change in a way that's getting rolled out gradually to all domains.

weseze’s picture

#3 fixed it for me to. (Drupal 6)

grendzy’s picture

Status: Needs work » Fixed

Fixed in all branches, and a 1.2 release is available.

govind.maloo’s picture

After updating to this version (7.x-1.2 ) reporting is not working at all on a watchdog I got following error message :

Code: 400 - Error: Bad Request - Message: GDatainvalidInvalid Value

moskito’s picture

Same of #17 here.

grendzy’s picture

Status: Fixed » Needs work

Huh. My own site seems to get these changes from Google later than others, so I can't yet reproduce it.

farald’s picture

Confirmed on 1.2.

Code in 1.2 release, line 349:

<?php
    //....
    /* Accept only strings, not arrays, for the following parameters */
    if (!empty($params['filters'])) $parameters['filters'] = $params['filters'];
    if (!empty($params['segment'])) $parameters['segment'] = $params['segment'];
    $parameters['start-index'] = $params['start_index'];
    $parameters['max-results'] = $params['max_results'];
    //....
?>

We have a custom module that utilizes GAR.
Will google use default values for those last 2 parameters start_index and max_results if they do not exist?
In that case I believe they should be allowed to be empty.

grendzy’s picture

According to https://developers.google.com/analytics/devguides/reporting/core/v3/refe... those parameters are optional, and default to 1 ond 1000 respectively.

xandeadx’s picture

Component: Code » Reports module

#3 works

raspberryman’s picture

Status: Needs work » Fixed

Latest GAFeed.lib.php has #3 and #20 pretty well covered. I'm leaving the 1-1000 counts in for now.

Note to self: More unit/integration tests :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.