Repository navigation
Commit 8f2035d
fix(cli): Name the scopes Sentry accepts when a 403 says which are missing (#2165)
Stacked on #2163.
Split out of #2160.
About 1% of `release set-commits` runs hit a 403 on the repos list: over
14 days, about 41k on 0.45 and 126 on 0.49. The repos list accepts
`org:ci` but not `project:releases`, so a personal token made for
releases fails there with no hint why. Since getsentry/sentry#118612,
Sentry lists the accepted scopes in `WWW-Authenticate: Bearer
error="insufficient_scope", scope="..."`. The CLI now shows them.
### Before
`release set-commits`, with a personal token in `SENTRY_AUTH_TOKEN` that
lacks `org:ci`:
```
Error: Failed to list repositories: 403 Forbidden
You do not have permission to perform this action.
Your SENTRY_AUTH_TOKEN token may lack the required scope for this operation.
Check token scopes at: <sentry-url>/settings/account/api/auth-tokens/
```
### After
```
Error: Failed to list repositories: 403 Forbidden
You do not have permission to perform this action.
Your SENTRY_AUTH_TOKEN token lacks the scope this request needs. Any one of these works: org:admin, org:ci, org:integrations, org:read, org:write.
An org auth token has org:ci. Create one in your organization's Settings > Auth Tokens.
Check token scopes at: <sentry-url>/settings/account/api/auth-tokens/
```
The second line depends on the credential that sent the request:
- **Org auth token, on an endpoint `org:ci` can't satisfy:** `Org auth
tokens only have org:ci. Use a personal token with one of these scopes
instead.`
- **`sentry auth login` session:** `Your login lacks the scope this
request needs. Any one of these works: …`, followed by `auth login
--force`, or `auth refresh --scope <default scopes>,<needed scope>` when
none of the default scopes is accepted.
Self-hosted servers older than getsentry/sentry#118612 don't send the
header, so they keep the "may lack the required scope" message.
<!-- junior-request-attribution:start -->
via @betegon.
<!-- junior-request-attribution:end -->
<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A28e783cd48c13b214d69caf6d8977a0c -->
--
[View Session in
Sentry](https://sentry.sentry.io/explore/conversations/agent%3A28e783cd48c13b214d69caf6d8977a0c/?project=4510944073809921)
<!-- junior-session-footer:end -->
---------
Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: bete <28983162+betegon@users.noreply.github.com>1 parent 263382d commit 8f2035d
3 files changed
Lines changed: 182 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
34 | 38 | | |
| 39 | + | |
35 | 40 | | |
36 | 41 | | |
37 | 42 | | |
| |||
53 | 58 | | |
54 | 59 | | |
55 | 60 | | |
| 61 | + | |
| 62 | + | |
56 | 63 | | |
57 | 64 | | |
58 | 65 | | |
59 | 66 | | |
60 | 67 | | |
61 | 68 | | |
62 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
63 | 128 | | |
64 | 129 | | |
65 | 130 | | |
| |||
69 | 134 | | |
70 | 135 | | |
71 | 136 | | |
72 | | - | |
| 137 | + | |
| 138 | + | |
73 | 139 | | |
74 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
75 | 144 | | |
76 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
77 | 149 | | |
78 | 150 | | |
79 | 151 | | |
| |||
92 | 164 | | |
93 | 165 | | |
94 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
95 | 172 | | |
96 | 173 | | |
97 | 174 | | |
| |||
195 | 272 | | |
196 | 273 | | |
197 | 274 | | |
198 | | - | |
| 275 | + | |
199 | 276 | | |
200 | 277 | | |
201 | 278 | | |
| 279 | + | |
202 | 280 | | |
203 | | - | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
204 | 285 | | |
205 | 286 | | |
206 | 287 | | |
| |||
397 | 478 | | |
398 | 479 | | |
399 | 480 | | |
400 | | - | |
| 481 | + | |
401 | 482 | | |
402 | 483 | | |
403 | 484 | | |
| |||
942 | 1023 | | |
943 | 1024 | | |
944 | 1025 | | |
945 | | - | |
| 1026 | + | |
946 | 1027 | | |
947 | 1028 | | |
948 | 1029 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
816 | 817 | | |
817 | 818 | | |
818 | 819 | | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
819 | 881 | | |
820 | 882 | | |
821 | 883 | | |
| |||
0 commit comments