Skip to content

Commit bb0499f

Browse files
committed
fix(errors): extend error status code supported by ggshield
1 parent ef7aa67 commit bb0499f

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!--
2+
A new scriv changelog fragment.
3+
4+
Uncomment the section that is right (remove the HTML comment wrapper).
5+
For top level release notes, leave all the headers commented out.
6+
-->
7+
8+
<!--
9+
### Removed
10+
11+
- A bullet item for the Removed category.
12+
13+
-->
14+
<!--
15+
### Added
16+
17+
- A bullet item for the Added category.
18+
19+
-->
20+
<!--
21+
### Changed
22+
23+
- A bullet item for the Changed category.
24+
25+
-->
26+
<!--
27+
### Deprecated
28+
29+
- A bullet item for the Deprecated category.
30+
31+
-->
32+
33+
### Fixed
34+
35+
- Extend the range of API error status code supported by ggshield so the UI correctly displays them.
36+
37+
<!--
38+
### Security
39+
40+
- A bullet item for the Security category.
41+
42+
-->

ggshield/core/errors.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,7 @@ def handle_api_error(detail: Detail) -> None:
213213
raise UnexpectedError(f"Scanning failed: {detail.detail}")
214214
if detail.status_code == 403 and detail.detail == "Quota limit reached.":
215215
raise QuotaLimitReachedError()
216+
if detail.status_code == 400 and "not found" in detail.detail:
217+
raise UnexpectedError(detail.detail)
218+
if 500 <= detail.status_code < 600:
219+
raise ServiceUnavailableError(detail.detail)

ggshield/verticals/secret/secret_scanner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def handle_scan_chunk_error(detail: Detail, chunk: List[Scannable]) -> None:
231231
details = None
232232

233233
# Handle source_uuid not found error specifically
234-
if "Source not found" in detail.detail:
234+
if "Source" in detail.detail and "not found" in detail.detail:
235235
ui.display_error("The provided source was not found in GitGuardian.")
236236
return
237237

0 commit comments

Comments
 (0)