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

Uncaught exception in API: Piwik\Exception\UnexpectedWebsiteFoundException: An unexpected website was found in the request: website id was set to '-1' . in core/Site.php #17759

Closed
tsteur opened this issue Jul 12, 2021 · 9 comments · Fixed by #17795
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc. Regression Indicates a feature used to work in a certain way but it no longer does even though it should.
Milestone

Comments

@tsteur
Copy link
Member

tsteur commented Jul 12, 2021

when calling MultiSites.getAll

#0 /plugins/SitesManager/API.php(244): Piwik\Site::setSiteFromArray(-1, false)
#1 /core/Site.php(480): Piwik\Plugins\SitesManager\API->getSiteFromId(-1)
#2 /core/Site.php(520): Piwik\Site::getFor(-1, 'name')
#3 [internal function]: Piwik\Site::getNameFor(-1)
#4 /core/DataTable/Filter/ColumnCallbackReplace.php(96): call_user_func_array('\\Piwik\\Site::ge...', Array)
#5 /core/DataTable.php(528): Piwik\DataTable\Filter\ColumnCallbackReplace->filter(Object(Piwik\DataTable))
#6 /core/DataTable.php(613): Piwik\DataTable->filter('Piwik\\DataTable...', Array)
#7 /core/API/DataTablePostProcessor.php(303): Piwik\DataTable->applyQueuedFilters()
#8 /core/API/DataTablePostProcessor.php(133): Piwik\API\DataTablePostProcessor->applyQueuedFilters(Object(Piwik\DataTable))
#9 /core/API/ResponseBuilder.php(190): Piwik\API\DataTablePostProcessor->process(Object(Piwik\DataTable))
#10 /core/API/ResponseBuilder.php(104): Piwik\API\ResponseBuilder->handleDataTable(Object(Piwik\DataTable))
#11 /core/API/Request.php(272): Piwik\API\ResponseBuilder->getResponse(Object(Piwik\DataTable), 'MultiSites', 'getAll')
#12 /core/Context.php(28): Piwik\API\Request->Piwik\API\{closure}()
#13 /core/API/Request.php(273): Piwik\Context::executeWithQueryParameters(Array, Object(Closure))
#14 /core/API/Request.php(559): Piwik\API\Request->process()
#15 /plugins/Cloud/Dao/SystemState.php(579): Piwik\API\Request::processRequest('MultiSites.getA...', Array)

Seems there is maybe an other row and https://github.com/matomo-org/matomo/blob/4.4.0-b1/plugins/MultiSites/API.php#L275 is applied maybe to the others row. Thinking this could be a regression from recent -1 changes.

Interestingly that instance has only 38 sites though so not sure it is caused by an others row but sounds like it. Maybe indirectly a lower limit was applied or so not sure.

@tsteur tsteur added Bug For errors / faults / flaws / inconsistencies etc. Regression Indicates a feature used to work in a certain way but it no longer does even though it should. labels Jul 12, 2021
@tsteur tsteur added this to the 4.4.0 milestone Jul 12, 2021
@sgiehl
Copy link
Member

sgiehl commented Jul 14, 2021

@tsteur do we maybe have the query string that caused the error?

@tsteur
Copy link
Member Author

tsteur commented Jul 14, 2021

It was during archiving

@tsteur
Copy link
Member Author

tsteur commented Jul 14, 2021

#18 [internal function]: Piwik\Plugins\Account2\Tasks->...(NULL)
#19 /core/Scheduler/Scheduler.php(266): call_user_func(Array, NULL)
#20 /core/Scheduler/Scheduler.php(138): Piwik\Scheduler\Scheduler->executeTask(Object(Piwik\Scheduler\Task))
#21 /plugins/CoreAdminHome/API.php(69): Piwik\Scheduler\Scheduler->run()
#22 /core/CronArchive.php(621): Piwik\Plugins\CoreAdminHome\API->runScheduledTasks()
#23 /core/CronArchive.php(264): Piwik\CronArchive->runScheduledTasks()
#24 /core/Access.php(664): Piwik\CronArchive->Piwik\{closure}()
#25 /core/CronArchive.php(269): Piwik\Access::doAsSuperUser(Object(Closure))
#26 /plugins/CoreConsole/Commands/CoreArchiver.php(32): Piwik\CronArchive->main()
#27 /vendor/symfony/console/Symfony/Component/Console/Command/Command.php(257): Piwik\Plugins\CoreConsole\Commands\CoreArchiver->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#28 /vendor/symfony/console/Symfony/Component/Console/Application.php(874): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#29 /vendor/symfony/console/Symfony/Component/Console/Application.php(195): Symfony\Component\Console\Application->doRunCommand(Object(Piwik\Plugins\CoreConsole\Commands\CoreArchiver), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#30 [internal function]: Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#31 /core/Console.php(130): call_user_func(Array, Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#32 /core/Access.php(673): Piwik\Console->Piwik\{closure}()
#33 /core/Console.php(131): Piwik\Access::doAsSuperUser(Object(Closure))
#34 /core/Console.php(82): Piwik\Console->doRunImpl(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#35 /vendor/symfony/console/Symfony/Component/Console/Application.php(126): Piwik\Console->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#36 /console(32): Symfony\Component\Console\Application->run()

@sgiehl
Copy link
Member

sgiehl commented Jul 16, 2021

I tried to reproduce that, but wasn't able to. It is actually triggered in a task of Account2 plugin, which calls

        $multiSites = Request::processRequest('MultiSites.getAll', array(
            'period' => 'range',
            'date' => $from . ',' . $to,
            'showColumns' => 'nb_actions,nb_pageviews'
        ));

Haven't yet figured out why there might occur a record holding -1 as label, but it seems to be returned here: https://github.com/matomo-org/matomo/blob/4.x-dev/plugins/MultiSites/API.php#L237

@diosmosis
Copy link
Member

diosmosis commented Jul 18, 2021

@sgiehl if you add 'filter_limit'=>-1 to Account2 do you still get the same issue?

EDIT: I'm guessing it happens if there's more than 100 sites.

@tsteur
Copy link
Member Author

tsteur commented Jul 18, 2021

If it's not easily reproducible we can also modify the milestone and remove "regression" label for now and wait until it happens again (if it does).

@sgiehl
Copy link
Member

sgiehl commented Jul 19, 2021

@diosmosis I wasn't able to reproduce that locally. Even when creating more than 100 sites, the MultiSites API still returns a valid result.
The request is sent without a third parameter for Request::processRequest, so the current request object is used. Maybe it contained some specific parameter during that archiving run that caused the failure? But I'm not sure what that could be. Tried to send various api parameters locally, but everything worked as expected.

@diosmosis
Copy link
Member

@sgiehl only other thing I can think of is filter_truncate which would add a summary row.

@sgiehl
Copy link
Member

sgiehl commented Jul 19, 2021

it seems to be filter_truncate. will check if it's easy to support that filter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. Regression Indicates a feature used to work in a certain way but it no longer does even though it should.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants