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

Sync Microsoft 365 Events In To Moodle - Task Fails #2609

Closed
aboarken opened this issue Jul 25, 2024 · 6 comments
Closed

Sync Microsoft 365 Events In To Moodle - Task Fails #2609

aboarken opened this issue Jul 25, 2024 · 6 comments
Assignees

Comments

@aboarken
Copy link

Please I am getting this task error after updating Moodle 4.4.1+ (Build: 20240719) and plugin to latest version. Kindly for your support.

Execute scheduled task: Sync Microsoft 365 events in to Moodle (local_o365\feature\calsync\task\importfromoutlook)
... started 22:33:49. Current memory use 30.1 MB.
Debugging increased temporarily due to faildelay of 86400
Syncing events for user #14003
... used 4 dbqueries
... used 0.01019287109375 seconds
Scheduled task failed: Sync Microsoft 365 events in to Moodle (local_o365\feature\calsync\task\importfromoutlook),Failed to parse time string (@2022-03-20T03:00:00.0000000 UTC) at position 8 (-): Double timezone specification
Backtrace:

  • line 1263 of /local/o365/classes/rest/unified.php: call to DateTime->__construct()
  • line 418 of /local/o365/classes/feature/calsync/main.php: call to local_o365\rest\unified->get_events()
  • line 75 of /local/o365/classes/feature/calsync/task/importfromoutlook.php: call to local_o365\feature\calsync\main->get_events()
  • line 410 of /lib/classes/cron.php: call to local_o365\feature\calsync\task\importfromoutlook->execute()
  • line 208 of /lib/classes/cron.php: call to core\cron::run_inner_scheduled_task()
  • line 125 of /lib/classes/cron.php: call to core\cron::run_scheduled_tasks()
  • line 186 of /admin/cli/cron.php: call to core\cron::run_main_process()
@grantcolin
Copy link

We have a similar error after upgrading to Moodle 4.4.1

Execute scheduled task: Cohort sync (local_o365\task\cohortsync)
... started 23:37:13. Current memory use 22.9 MB.
Debugging increased temporarily due to faildelay of 61440
... used 0 dbqueries
... used 0.036664009094238 seconds
Scheduled task failed: Cohort sync (local_o365\task\cohortsync),Could not get app or system token.
Backtrace:

  • line 453 of /local/o365/classes/feature/cohortsync/main.php: call to local_o365\utils::get_application_token()
  • line 52 of /local/o365/classes/task/cohortsync.php: call to local_o365\feature\cohortsync\main::get_unified_api()
  • line 410 of /lib/classes/cron.php: call to local_o365\task\cohortsync->execute()
  • line 208 of /lib/classes/cron.php: call to core\cron::run_inner_scheduled_task()
  • line 125 of /lib/classes/cron.php: call to core\cron::run_scheduled_tasks()
  • line 186 of /admin/cli/cron.php: call to core\cron::run_main_process()

@dragos5436
Copy link

dragos5436 commented Jul 29, 2024

Hi there,

We have been experiencing the same Cohort sync task failure as above for a while now. It seems to be a scheduled task supposed to run every day. As @grantcolin mentions, we discovered it after upgrading to Moodle 4.4.1 last week (an update in 4.4 pushes notifications to us now about these task failures). However, after checking the logs, it looks like the task has been failing every day since July 1st for us, so probably not related to the upgrade itself. Here is a failure message example (personal data has been removed):

 Execute scheduled task: Cohort sync (local_o365\task\cohortsync)
 ... started 14:08:41. Current memory use 13.6 MB.
 Debugging increased temporarily due to faildelay of 86400
 ... Start updating groups cache.
 ...... Added group ID 9a51bfae-90f2-44dd-8515-8f5ab61d10a4 to cache.
 ...... Added group ID 9a52bb34-1e34-42c5-b106-454b8b68e247 to cache.
 ... used 89361 dbqueries
 ... used 711.84796905518 seconds
 Scheduled task failed: Cohort sync (local_o365\task\cohortsync),Error writing to database (Data too long for column 'name' at row 1
 INSERT INTO mdl_local_o365_groups_cache (objectid,name,description) VALUES(?,?,?)
 [array (
   0 => 'b4725107-2fc0-4d83-aba6-d93181b260be',
   1 => 'username1@emailaddress; username2@emailaddress; username3@emailaddress; username4@emailaddress; username5@emailaddress; username6@emailaddress; username7@emailaddress; username8@emailaddress; username9@emailaddress',
   2 => NULL,
 )])
 Debug info:
 Data too long for column 'name' at row 1
 INSERT INTO mdl_local_o365_groups_cache (objectid,name,description) VALUES(?,?,?)
 [array (
   0 => 'b4725107-2fc0-4d83-aba6-d93181b260be',
   1 => 'username1@emailaddress; username2@emailaddress; username3@emailaddress; username4@emailaddress; username5@emailaddress; username6@emailaddress; username7@emailaddress; username8@emailaddress; username9@emailaddress',
   2 => NULL,
 )]
 Backtrace:
 * line 293 of /lib/dml/moodle_read_slave_trait.php: call to moodle_database->query_end()
 * line 1482 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->query_end()
 * line 1528 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
 * line 244 of /local/o365/classes/feature/cohortsync/main.php: call to mysqli_native_moodle_database->insert_record()
 * line 72 of /local/o365/classes/task/cohortsync.php: call to local_o365\feature\cohortsync\main->update_groups_cache()
 * line 60 of /local/o365/classes/task/cohortsync.php: call to local_o365\task\cohortsync->execute_sync()
 * line 410 of /lib/classes/cron.php: call to local_o365\task\cohortsync->execute()
 * line 208 of /lib/classes/cron.php: call to core\cron::run_inner_scheduled_task()
 * line 125 of /lib/classes/cron.php: call to core\cron::run_scheduled_tasks()
 * line 186 of /admin/cli/cron.php: call to core\cron::run_main_process()

Could you please investigate the cause of this task failure and provide a solution for fixing it?

Thank you.

Moodle version: 4.4.1
Microsoft plugins version:

  • auth_oidc: 2024042200
  • local_o365: 2024042200

PHP version: 8.1
Database version: MySQL 8.0.32

@weilai-irl weilai-irl self-assigned this Sep 27, 2024
@weilai-irl
Copy link
Collaborator

@aboarken
This is the same issue as #2589 , which has been fixed in the release from June 2024. Please check out the latest version of the plugins for the fix.

@grantcolin
The issue you are facing is different from the one originally reported in this. You can fix the issue by provide admin consent in the local_o365 configuration page again, and verify setup by clicking the button also on the configuration page.

@dragos5436
The issue you reported is also different, and it should be reported as a separate issue. I have a theory why the error happened to you, and I'll need you to confirm it for me. I assume the group name you put in the note is not real, but could you confirm the length of your group name in the real task output please? Please put it in new issue that you can going to create. We may have a quick solution for you.

Since the issue from the OP is resolved, I'm going to close this issue.

Regards,
Lai

@weilai-irl
Copy link
Collaborator

@dragos5436

FYI, I confirmed my theory. I'll provide a solution for the next release.

Microsoft group names can take 256 character, while the Moodle database table to store the group cache can store 255. If you try to save group cache for a group with 256 characters in the name, you will see the error.

Please create a new issue so that I can link the solution.

Regards,
Lai

@dragos5436
Copy link

dragos5436 commented Sep 27, 2024

To answer your question @weilai-irl, yes, I have edited the email addresses listed after '1 =>' in the array above. I'm assuming these would go under the field 'name' in the mdl_local_o365_groups_cache table. I just checked the original error message and the total length of this entry is 256 characters.

@dragos5436
Copy link

Issue created: #2641

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants