Handle unauthorized org membership check gracefully#253
Handle unauthorized org membership check gracefully#253arnavk23 wants to merge 4 commits intoJuliaWeb:masterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #253 +/- ##
==========================================
- Coverage 58.45% 57.86% -0.59%
==========================================
Files 37 37
Lines 982 985 +3
==========================================
- Hits 574 570 -4
- Misses 408 415 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thanks for splitting this out! I think we might have to give this some thought. So, if I understand correctly, there are three possible cases:
We already detect Case 1 - the result is stored in the @arnavk23 Can you write some logic to detect case 2 vs case 3, without using try-catch? You'll want to use the "List organizations for the authenticated user" API. I don't know if that API is currently supported by GitHub.jl, so it might be helpful if you could add it. Once we have the ability to distinguish between case 2 and case 3, I think we should then use the following logic:
Here, when I say "the @test GitHub.check_membership(julweb, testuser; auth = auth)Does that make sense? This way, instead of using try-catch (which might mask an error that we actually want to surface), we can more specifically run or skip the test based on the specific circumstances. |
Summary
Replace the conditional skip for org membership tests with a try-catch that gracefully handles unauthorized access (when the token lacks org permissions), skipping the test instead of erroring.
Testing
julia --project -e 'using Pkg; Pkg.test(; test_args=["read_only_api_tests"])'passes with tokens that have org access.