Commit 653af66
committed
Fix scoped installation-token mint that always failed at runtime
**Impact:** pytorch-advisor-coverage lambda (token minting for workflow_dispatch)
**Risk:** low
## What
Mint the scoped installation token via `GithubIntegration.get_access_token` instead of reading `.token` off a standalone `Auth.AppInstallationAuth`, and wrap the call so mint failures name the App and installation ids.
## Why
On PyGithub 2.6.1 `Auth.AppInstallationAuth` only builds its internal integration inside `withRequester`, which never runs until the auth is handed to a `github.Github(...)`. Reading `.token` off the standalone instance therefore always asserts, so the old code path could never actually mint a token at runtime. The previous test passed only because the whole `github` module was mocked, hiding the bug.
# Notes
The test now patches only `GithubIntegration`, exercising the real PyGithub call path so a mint that can't produce a token fails in CI rather than silently passing. A second test covers the wrapped error message, which surfaces the App/installation ids to distinguish a wrong-App key ("A JSON web token could not be decoded") from a genuine outage. Token scoping (`actions:write` only) is unchanged.
Signed-off-by: Jean Schmidt <contato@jschmidt.me>1 parent 5232da6 commit 653af66
2 files changed
Lines changed: 49 additions & 16 deletions
File tree
- aws/lambda/pytorch-advisor-coverage/advisor_coverage
- tests
Lines changed: 20 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
100 | 106 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
108 | 120 | | |
109 | 121 | | |
110 | 122 | | |
| |||
Lines changed: 29 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
835 | 835 | | |
836 | 836 | | |
837 | 837 | | |
838 | | - | |
839 | | - | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
840 | 845 | | |
841 | 846 | | |
842 | | - | |
843 | | - | |
844 | | - | |
| 847 | + | |
| 848 | + | |
845 | 849 | | |
846 | 850 | | |
847 | | - | |
848 | | - | |
849 | | - | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
850 | 871 | | |
851 | 872 | | |
852 | 873 | | |
| |||
0 commit comments