fix: propagate 403 from multi-region fan-out instead of returning empty list (CLI-89)#507
Merged
fix: propagate 403 from multi-region fan-out instead of returning empty list (CLI-89)#507
Conversation
…ty list (CLI-89) Follow-up to PR #498. The enriched 403 error with token scope guidance was silently swallowed by the multi-region fan-out's catch block in listOrganizationsUncached. When ALL regions returned 403 (token lacks org:read scope), users got an empty org list instead of the helpful error message — negating the purpose of the enrichment. Changed Promise.all + try/catch to Promise.allSettled with explicit error tracking: - Transient failures (network, 5xx) are still swallowed per region - 403 errors are tracked; if ALL regions fail with 403, the enriched error is re-thrown so users see the scope guidance - Partial success (some regions 403, others OK) returns available orgs Added 3 tests: - listOrganizationsInRegion: enriches 403 with scope guidance - Fan-out: propagates 403 when all regions return 403 - Fan-out: returns partial results when only some regions 403
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ 126 passed | Total: 126 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 1043 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 95.72% 95.79% +0.07%
==========================================
Files 180 180 —
Lines 24745 24758 +13
Branches 0 0 —
==========================================
+ Hits 23687 23715 +28
- Misses 1058 1043 -15
- Partials 0 0 —Generated by Codecov Action |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Address Bugbot: a region returning 200 OK with zero orgs (user has no memberships there) is still a successful response. Only throw the 403 error when NO region succeeded at all, not when flatResults is empty.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Follow-up to PR #498
Addresses two missed review comments:
filter(Boolean)removes blank line separator (already fixed in PR fix: enrich 403 on org listing with token scope guidance (CLI-89) #498's second commit)Also fixes the low patch coverage (~35%) from PR #498 by adding 3 tests.
Problem
PR #498 added helpful token-scope guidance to 403 errors from
listOrganizationsInRegion. ButlistOrganizationsUncachedwraps the region calls intry { ... } catch { return []; }, silently swallowing the enriched error. On SaaS (multi-region), users with a token lackingorg:readscope would get an empty org list instead of the guidance message.Fix
Changed the multi-region fan-out from
Promise.all+ try/catch toPromise.allSettledwith explicit error tracking:Tests Added
enriches 403 error with token scope guidancelistOrganizationsInRegionaddsorg:readhint to 403 errorspropagates 403 error when all regions return 403returns partial results when some regions return 403