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

Invalid Team ID #1816

Open
OscarTheFabulous opened this issue Sep 14, 2021 · 4 comments
Open

Invalid Team ID #1816

OscarTheFabulous opened this issue Sep 14, 2021 · 4 comments
Assignees
Labels
Feature - teams integration Issue type - help wanted General questions on how to use the plugins, e.g. configurations etc. Plugin - local_o365 Status - need more info Further information requested to triage the issue.

Comments

@OscarTheFabulous
Copy link

OscarTheFabulous commented Sep 14, 2021

Greetings!
We are having this issue right now. Graph API is connected, everything else seems to be working.
Please note that this issue just stopped our workflow, we are unable to create new teams and have to rely on other platforms in order to continue our work.

Here is the output from the modified groupcreate.php task with var_dump on line 349

string(1808) "{"error":{"code":"BadRequest","message":"Failed to execute Templates backend request CreateTeamFromTemplateRequest. Request Url: https://teams.microsoft.com/fabric/emea/templates/api/team, Request Method: POST, Response Status Code: BadRequest, Response Headers: Strict-Transport-Security: max-age=2592000\r\nx-operationid: bd692c8ae97a1149ae487cd91cdf7e1a\r\nx-telemetryid: 00-bd692c8ae97a1149ae487cd91cdf7e1a-89b00de86272fe49-00\r\nX-MSEdge-Ref: Ref A: 92D081F92EFA4D91B444F2A3767A78A5 Ref B: VIEEDGE3010 Ref C: 2021-09-14T10:43:06Z\r\nDate: Tue, 14 Sep 2021 10:43:06 GMT\r\n, ErrorMessage : {"errors":[{"message":"Error when calling Middle Tier. Message: ''. Error code: 'UnableToGenerateValidTeamAlias'. Status code: BadRequest.","errorCode":"Unknown"}],"operationId":"bd692c8ae97a1149ae487cd91cdf7e1a"}","innerError":{"message":"Failed to execute Templates backend request CreateTeamFromTemplateRequest. Request Url: https://teams.microsoft.com/fabric/emea/templates/api/team, Request Method: POST, Response Status Code: BadRequest, Response Headers: Strict-Transport-Security: max-age=2592000\r\nx-operationid: bd692c8ae97a1149ae487cd91cdf7e1a\r\nx-telemetryid: 00-bd692c8ae97a1149ae487cd91cdf7e1a-89b00de86272fe49-00\r\nX-MSEdge-Ref: Ref A: 92D081F92EFA4D91B444F2A3767A78A5 Ref B: VIEEDGE3010 Ref C: 2021-09-14T10:43:06Z\r\nDate: Tue, 14 Sep 2021 10:43:06 GMT\r\n, ErrorMessage : {"errors":[{"message":"Error when calling Middle Tier. Message: ''. Error code: 'UnableToGenerateValidTeamAlias'. Status code: BadRequest.","errorCode":"Unknown"}],"operationId":"bd692c8ae97a1149ae487cd91cdf7e1a"}","code":"BadRequest","innerError":{},"date":"2021-09-14T10:43:07","request-id":"c9c61324-3b40-40f4-af78-f8e8e378dbf8","client-request-id":"c9c61324-3b40-40f4-af78-f8e8e378dbf8"}}}"
Could not create class team for #13514. Reason: invalid team ID
Syncing group membership for course #13514
Could not find group object ID in local_o365_objects for course 13514. Please ensure group exists first.

Moodle 3.11.3 (Build: 20210913)
local_o365 3.11.0 (2021051700)

Originally posted by @OscarTheFabulous in #1784 (comment)

@weilai-irl weilai-irl self-assigned this Oct 4, 2021
@weilai-irl
Copy link
Collaborator

Hi @OscarTheFabulous,

Thank you for reporting the issue. This is the first time I saw this particular issue. I think the best thing to do is to analyse the exact parameters used to call the Graph API to create the class team, and try the same from Graph Explorer to see if it works.

The Graph API call to create class team is at

public function create_class_team($displayname, $description, $ownerid, $extra = null) {
$owneridparam = ["https://graph.microsoft.com/beta/users/{$ownerid}"];
$description = substr($description, 0, 1024); // API restricts length to 1024 chars.
$teamdata = [
'displayName' => $displayname,
'description' => $description,
'[email protected]' => $owneridparam,
];
$classteampreference = get_config('local_o365', 'prefer_class_team');
if ($classteampreference === false || $classteampreference == '1') {
$teamdata['[email protected]'] = "https://graph.microsoft.com/beta/teamsTemplates('educationClass')";
} else {
$teamdata['[email protected]'] = "https://graph.microsoft.com/beta/teamsTemplates('standard')";
}
if (!empty($extra) && is_array($extra)) {
foreach ($extra as $name => $value) {
$teamdata[$name] = $value;
}
}
if (empty($teamdata['description'])) {
unset($teamdata['description']);
}
return $this->betaapicall('post', '/teams', json_encode($teamdata));
}
.
Please add var_dump() to output the $teamdata, and see what it contains.

When you have it, and you don't see anything obvious, go to Graph Explorer at https://developer.microsoft.com/en-us/graph/graph-explorer, login using your account, and try to make the same call and same parameters, and see if it produces the same error.

You may want to check the permissions required for the call as well and ensure your app has them as well, although the error message doesn't indicate it's permission related.

Regards,
Lai

@weilai-irl weilai-irl added Feature - teams integration Issue type - help wanted General questions on how to use the plugins, e.g. configurations etc. Plugin - local_o365 Status - need more info Further information requested to triage the issue. labels Oct 4, 2021
@OscarTheFabulous
Copy link
Author

Thanks for your reply!
That was interesting.
Most of our courses contain only cyrillic characters in their names, which look like [U] [СИЭ] Муниципальное право (заочное).
It seems that Graph strips away all these characters when creating an alias, leaving only the U prefix and adding the serial number.
However, it appears that it cannot add more than 999 and therefore cannot create more teams.
Adding a suffix to the name in the plugin settings seems to temporarily fix the issue, however, we'll have to change it every thousandth team, which doesn't really solve the problem.
I'd suggest adding a transliteration function for non-latin characters, but I don't know if it's possible to set custom alias when creating a team.

@weilai-irl
Copy link
Collaborator

Hi @OscarTheFabulous,

The Cyrillic characters would explain many issue that you experienced. The action to add random 3 digits to team names is completely on Microsoft side, and the Moodle plugin has no control over it.

However, there is a possible solution to it - besides adding a prefix to the team name, it's also possible to use other course fields in the team name. The available options are:

  • Full name (default)
  • Short name
  • Moodle created ID
  • ID number (the one configurable on the edit course details page, note this doesn't need to be a number, any string will do; also note this is an optional course setting, and doesn't need to be unique).
    You can consider using either the short name or the ID number field, providing they contain utf8 characters.

The setting is called "Course part of the Teams name" and can be found in the "Teams name" section in "Sync Settings" tab, just below you prefix is configured.

Regards,
Lai

@OscarTheFabulous
Copy link
Author

Greetings! Thank you for your help.

We would like to keep course names as is, adding other codes or characters might confuse our users.

However, Microsoft Graph behavior while handling Cyrillic characters isn't normal. I'm thinking about writing a feature request to Microsoft for handling non-Latin characters, but I don’t know where to leave it.

In any case, can we have more distinct error messages in the future versions of the plugin? That would be so much helpful than just "Invalid Team ID".

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature - teams integration Issue type - help wanted General questions on how to use the plugins, e.g. configurations etc. Plugin - local_o365 Status - need more info Further information requested to triage the issue.
Projects
None yet
Development

No branches or pull requests

2 participants