Commit 806bc96
authored
fix(api): distinguish 401 (auth failure) from 403 (permissions) (#1226)
Backport of v1.x #1145 to main. Previously main returned the same
"access denied / lacks required permissions" message for both 401
and 403, which was misleading when the user's real problem was a
revoked/expired API token — it sent them chasing permissions
instead of re-authenticating.
Changes:
* `utils/socket/api.mts` `getErrorMessageForHttpStatusCode` — split
401 and 403 into separate branches with distinct, actionable
guidance (re-auth vs. check permissions).
* `commands/scan/perform-reachability-analysis.mts` — when the
enterprise-plan check fails with a 401, return "Authentication
failed" + token-focused guidance instead of the generic
"Unable to verify plan permissions" message.
* Updated the matching unit test assertion for the 401 branch.
Skipped from v1.x's version: the extra `logger.fail` in
`fetch-organization-list.mts`. Main's `handleApiCall` already wires
the cause into the returned CResult; a caller-level log would
double-log in many paths.1 parent 4c26d1d commit 806bc96
File tree
3 files changed
+24
-2
lines changed- packages/cli
- src
- commands/scan
- utils/socket
- test/unit/utils/socket
3 files changed
+24
-2
lines changedLines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
84 | 94 | | |
85 | 95 | | |
86 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
167 | 176 | | |
168 | 177 | | |
169 | 178 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
177 | 180 | | |
178 | 181 | | |
179 | 182 | | |
| |||
0 commit comments