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

Deprecated GitHub API endpoint for teams #135

Open
raimue opened this issue Mar 1, 2022 · 2 comments
Open

Deprecated GitHub API endpoint for teams #135

raimue opened this issue Mar 1, 2022 · 2 comments

Comments

@raimue
Copy link
Contributor

raimue commented Mar 1, 2022

The trac-github plugin is using a deprecated GitHub API endpoint for /teams/ that will be removed on 2022-03-15. Right now on 2022-03-01, GitHub has some brownouts in effect to make users of the API aware of the deprecation. I see the following log message:

Trac[github] ERROR: Error communicating with GitHub API at https://api.github.com/teams/3156412/members: You are receiving this error due to a service brownout. Please see https://github.blog/changelog/2022-02-22-sunset-notice-deprecated-teams-api-endpoints/ for more information.

The easiest route seems to be to replace the /teams/ endpoint with /organizations/:org_id/team/:team_id. I have not yet checked whether they are fully compatible, though.

@neverpanic
Copy link
Member

The required patch probably is the following. I need to do more testing, though.

diff --git a/runtests.py b/runtests.py
index 62f5127..69b8fb6 100755
--- a/runtests.py
+++ b/runtests.py
@@ -1482,8 +1482,8 @@ class GitHubGroupsProviderTests(TracGitHubTests):
                     "slug": u"gentlepeople"
                 }
             ],
-            '/teams/1/members': team1members,
-            '/teams/12/members': team12members
+            '/organizations/%s/team/1/members' % self.organization: team1members,
+            '/organizations/%s/team/12/members' % self.organization: team12members
         })
 
         with TracContext(self, env=self.tracd_env_debug, **self.trac_env):
@@ -1665,8 +1665,8 @@ class GitHubGroupsProviderTests(TracGitHubTests):
                     "slug": u"gentlepeople"
                 }
             ],
-            '/teams/1/members': team1members,
-            '/teams/12/members': team12members
+            '/organizations/%s/team/1/members' % self.organization: team1members,
+            '/organizations/%s/team/12/members' % self.organization: team12members
         })
 
         update = {
@@ -1698,7 +1698,7 @@ class GitHubGroupsProviderTests(TracGitHubTests):
                         "slug": u"gentlepeople"
                     }
                 ],
-                '/teams/12/members': team12members
+                '/organizations/%s/team/12/members' % self.organization: team12members
             })
 
             # Send the delete event
@@ -1783,7 +1783,7 @@ class GitHubGroupsProviderTests(TracGitHubTests):
                         "slug": u"justice-league"
                     },
                 ],
-                '/teams/1/members': team1members,
+                '/organizations/%s/team/1/members' % self.organization: team1members,
             })
 
             # Send the update event
@@ -1826,7 +1826,7 @@ class GitHubGroupsProviderTests(TracGitHubTests):
                     "slug": u"justice-league"
                 },
             ],
-            '/teams/1/members': list(team1members)
+            '/organizations/%s/team/1/members' % self.organization: list(team1members)
         })
 
         update = {
@@ -1848,7 +1848,7 @@ class GitHubGroupsProviderTests(TracGitHubTests):
                         "slug": u"justice-league"
                     },
                 ],
-                '/teams/1/members': list(team1members)
+                '/organizations/%s/team/1/members' % self.organization: list(team1members)
             })
 
             # Send the update event
@@ -1891,7 +1891,7 @@ class GitHubGroupsProviderTests(TracGitHubTests):
                     "slug": u"justice-league"
                 },
             ],
-            '/teams/1/members': list(team1members)
+            '/organizations/%s/team/1/members' % self.organization: list(team1members)
         })
 
         update = {
@@ -1913,7 +1913,7 @@ class GitHubGroupsProviderTests(TracGitHubTests):
                         "slug": u"justice-league"
                     },
                 ],
-                '/teams/1/members': list(team1members)
+                '/organizations/%s/team/1/members' % self.organization: list(team1members)
             })
 
             # Send the update event
diff --git a/tracext/github/__init__.py b/tracext/github/__init__.py
index 0dddb2b..fe9dc6f 100644
--- a/tracext/github/__init__.py
+++ b/tracext/github/__init__.py
@@ -475,11 +475,12 @@ class GitHubTeam(GitHubUserCollection):
         :param slug: the GitHub team shortname in URL representation
         """
         self._teamid = teamid
+        self._orgid = org
         fullname = '-'.join(['github', org, slug])
         super(GitHubTeam, self).__init__(api, env, fullname)
 
     def _apicall_parameters(self):
-        return ("teams/{}/members", self._teamid)
+        return ("organizations/{}/team/{}/members", self._orgid, self._teamid)
 
 #class GitHubOrgMembers(GitHubUserCollection):
 #    """

@raimue
Copy link
Contributor Author

raimue commented Mar 7, 2022

GitHub moved the sunset of the teams API endpoint to an unannounced later date. This gives us more time for testing this properly, but we should still move to the newer API endpoint eventually.

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

2 participants