Discourse group sync fail due to un recoverable groups ID
Hi,
Since few weeks, my AA instance is non longer able to assign groups to my discourse users. After few investigation, it seems AA is not handling paginated response (which are not documented by the way - blame discourse team).
As I've understood the AA flow :
- collecting user
- retrieving attached groups
- collecting groups from Discourse API in order to resolve their name into ID
- send request to Discourse API in order to assign missing groups to the user
In my case, I've an user which should get a group available on the second page when fetching groups list. As a result, I'm seeing this notification in AA
Discourse execution failed.
Endpoint: {'path': '/admin/groups/%s/members.json', 'method': 'put', 'args': {'required': ['usernames'], 'optional': []}, 'parsed_url': '/admin/groups/None/members.json'}
Errors: ['You are not permitted to view the requested resource.']
I assume None
is Python equivalent of null as the algorithm is calling an array entry without value (even if the entry exists itself).
Discourse API response
Discourse API response of groups.json
is the one bellow :
{
"groups": [
],
"extras": {
"type_filters": [
"my",
"owner",
"public",
"close",
"automatic"
]
},
"total_rows_groups": 57,
"load_more_groups": "/groups?page=1"
}
groups
attribute is containing a list of 30 groups object maximum.
total_rows_groups
is the total groups available (meaning, 27 of them are on the next page)
load_more_groups
is containing the endpoint with parameter set in order to retrieve the next page (seems paging is starting at 0). Also, it seems the attribute name is tied to the endpoint itself. I assume other will have something like load_more_endpointname
But, all endpoint seems not to be paginated (ie: user list is not)
Tracking
-
https://gitlab.com/allianceauth/allianceauth/blob/master/allianceauth/services/modules/discourse/manager.py#L352
update_groups(user)
-
https://gitlab.com/allianceauth/allianceauth/blob/master/allianceauth/services/modules/discourse/manager.py#L249
__generate_group_dict(names)
-
https://gitlab.com/allianceauth/allianceauth/blob/master/allianceauth/services/modules/discourse/manager.py#L214
__group_name_to_id(name)
-
https://gitlab.com/allianceauth/allianceauth/blob/master/allianceauth/services/modules/discourse/manager.py#L193
_get_groups
-
https://gitlab.com/allianceauth/allianceauth/blob/master/allianceauth/services/modules/discourse/manager.py#L152
__exc(endpoint, *args, **kwargs)