fix: (regression beta) admin/plugins/search: error 422
Massimo Melina committed
May 15, 2024 at 11:35 UTC
d0b21c53aa92e42e9978d1a507e43c08ff9f2ef4
1 file changed
+13
-7
src/github.ts
+13
-7
@@ -162,13 +162,19 @@ async function *apiGithubPaginated<T=any>(uri: string) {
162
const PAGE_SIZE = 100
163
let page = 1
164
let n = 0
165
- while (1) {
166
- const res = await apiGithub(uri + `&page=${page++}&per_page=${PAGE_SIZE}`)
167
- for (const x of res.items)
168
- yield x as T
169
- const now = res.items.length
170
- n += now
171
- if (!now || n >= res.total_count) break
165
+ try {
166
+ while (1) {
167
+ const res = await apiGithub(uri + `&page=${page++}&per_page=${PAGE_SIZE}`)
168
+ for (const x of res.items)
169
+ yield x as T
170
+ const now = res.items.length
171
+ n += now
172
+ if (!now || n >= res.total_count) break
173
+ }
174
+ }
175
+ catch(e: any) {
176
+ if (e.message !== '422') // for some strange reason github api is returning this error if we search repos for a missing user, instead of empty set
177
+ throw e
178
}
179
}
180