Skip to content

Commit

Permalink
fix: fix fallback system in GH (again) (#245)
Browse files Browse the repository at this point in the history
I broke the GH fallback system again 😅
Fixes this issue: https://l.codecov.dev/dEsZeK

The problem is that since #225
(technically codecov/worker#470 actually) we include 1 extra piece of information in `GitHubAppInstallationInfo`, the `GitHubAppInstallation.id`.

This is breaking the function that gets tokens because we are destructuring the info dict
into the kwargs for the function (with the extra, unexpected `id` one).

To fix that we just pop it before calling the function.
  • Loading branch information
giovanni-guidini committed Jun 10, 2024
1 parent 9de2b01 commit f7e798b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions shared/torngit/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ def _get_next_fallback_token(
installation_info = fallback_installations.pop(0)
# The function arg is 'integration_id'
installation_id = installation_info.pop("installation_id")
obj_id = installation_info.pop("id", None)
token_to_use = get_github_integration_token(
self.service, installation_id, **installation_info
)
Expand All @@ -747,6 +748,7 @@ def _get_next_fallback_token(
self.data["installation"] = {
# Put the installation_id back into the info
"installation_id": installation_id,
"id": obj_id,
**installation_info,
}
return token_to_use
Expand Down
7 changes: 6 additions & 1 deletion tests/unit/torngit/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,12 @@ async def test_update_check_run_url_fallback(self, mocker):
installation_id=1500,
),
fallback_installations=[
{"installation_id": 12342, "app_id": 1200, "pem_path": "some_path"}
{
"installation_id": 12342,
"app_id": 1200,
"pem_path": "some_path",
"id": 20,
}
],
)

Expand Down

0 comments on commit f7e798b

Please sign in to comment.