Commit 078eeb9
fix(integrations): cache empty repo 409 responses to reduce GitHub API calls (#109153)
Cache the result when GitHub's Git Trees API returns a 409 ("Git
Repository
is empty") instead of re-fetching on every task run.
Previously, when `get_tree` hit a 409 for an empty repo, the exception
propagated without writing to cache. This meant every subsequent
`auto_source_code_config` task run would re-fetch the same empty repos,
wasting API calls and contributing to GitHub rate limiting. For large
orgs
with many empty repos, this adds up to thousands of unnecessary API
calls
per day.
Now we catch `ApiConflictError` in `get_cached_repo_files`, cache an
empty
list with the same TTL as successful results (24h + staggered offset),
and
return early. The existing error handling in `_populate_trees` is
unaffected
since the exception no longer propagates.
Pairs with #109134 which records these 409s as halts instead of failures
in the interaction event lifecycle.
Refs SENTRY-5K7F1 parent 44a475d commit 078eeb9
File tree
2 files changed
+21
-5
lines changed- src/sentry/integrations/source_code_management
- tests/sentry/integrations/github
2 files changed
+21
-5
lines changedLines changed: 12 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
202 | | - | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
203 | 213 | | |
204 | 214 | | |
205 | 215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
899 | 899 | | |
900 | 900 | | |
901 | 901 | | |
902 | | - | |
| 902 | + | |
| 903 | + | |
903 | 904 | | |
904 | 905 | | |
905 | 906 | | |
| 907 | + | |
906 | 908 | | |
907 | 909 | | |
908 | 910 | | |
| |||
983 | 985 | | |
984 | 986 | | |
985 | 987 | | |
| 988 | + | |
986 | 989 | | |
987 | 990 | | |
988 | 991 | | |
| |||
1007 | 1010 | | |
1008 | 1011 | | |
1009 | 1012 | | |
| 1013 | + | |
1010 | 1014 | | |
1011 | 1015 | | |
1012 | 1016 | | |
1013 | 1017 | | |
1014 | 1018 | | |
1015 | 1019 | | |
| 1020 | + | |
1016 | 1021 | | |
1017 | 1022 | | |
1018 | 1023 | | |
| |||
1059 | 1064 | | |
1060 | 1065 | | |
1061 | 1066 | | |
1062 | | - | |
1063 | | - | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
1064 | 1070 | | |
1065 | 1071 | | |
1066 | 1072 | | |
| |||
0 commit comments