Error reported when trying to send an email report

The nightly cron reports strange permission error when trying to send an email report:


Error in the last Piwik archive.php run: 
1 total errors during this script execution, please investigate and try and fix these errors. First error was: Got invalid response from API request: http://XXX.de/index.php?module=API&method=CoreAdminHome.runScheduledTasks&format=csv&convertToUnicode=0&token_auth=XXX&trigger=archivephp. Response was 'task,output
CoreAdminHome.purgeOutdatedArchives,Time elapsed: 0.839s
API.sendReport_2,"ERROR: Sie können auf die Ressource nicht zugreifen, da Sie dafür mindestens 'view' Rechte benötigen."
PrivacyManager.deleteReportData,Time elapsed: 0.018s
PrivacyManager.deleteLogData,Time elapsed: 0.001s
Piwik\Plugins\CorePluginsAdmin\MarketplaceApiClient.clearAllCacheEntries,Time elapsed: 0.045s
CoreAdminHome.optimizeArchiveTable,Time elapsed: 0.498s
DBStats.cacheDataByArchiveNameReports,Time elapsed: 33.870s'


This seems to happen for just one piwik instance here and I don’t understand it as archiving otherwise works and it should use the superuser, isn’t it?

Regards,

Thomas

that’s indeed surprising! are you using 2.2.2 on this instance?
if so could you send the row from piwik_report table for this report id=2 ?

Yes, thats Piwik 2.2.2.

Here is the row:


INSERT INTO `statreport` (`idreport`, `idsite`, `login`, `description`, `idsegment`, `period`, `hour`, `type`, `format`, `reports`, `parameters`, `ts_created`, `ts_last_sent`, `deleted`) VALUES
(2, 2, 'XXX-stat-XXX', 'Besuche Ihrer Seiten', NULL, 'week', 0, 'email', 'pdf', '["VisitsSummary_get","VisitTime_getVisitInformationPerServerTime","VisitTime_getByDayOfWeek","Actions_getPageUrls","Actions_getPageTitles","Referrers_getAll","UserCountry_getRegion","UserCountry_getCity","VisitorInterest_getNumberOfVisitsPerVisitDuration","VisitFrequency_get"]', '{"displayFormat":"3","emailMe":true,"evolutionGraph":true}', '2013-06-13 19:57:30', '2014-03-17 22:43:53', 0);

Looking at the row I might just see the problem.
The login (anonymized) XXX-stat-XXX doesn’t exist in the users table anymore. Should this case not be handled more gracefully?
I think I can just set another user there …

Thanks,

Thomas

Reports should be deleted when users are deleted!

done in: https://github.com/piwik/piwik/blob/master/plugins/ScheduledReports/ScheduledReports.php#L563-567

which should be called from Events - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3

-> you may delete this row to solve the problem