Handle GitHub 422 errors as commit_not_found and sanitize error responses

This commit is contained in:
tdurieux
2026-05-07 05:54:51 +03:00
parent 9403f15ac3
commit 9292c19392
+2 -2
View File
@@ -64,7 +64,7 @@ export class GitHubRepository {
return commit.data; return commit.data;
} catch (error) { } catch (error) {
const status = (error as { status?: number }).status; const status = (error as { status?: number }).status;
if (status === 404) { if (status === 404 || status === 422) {
// Distinguish: does the repo itself still exist? // Distinguish: does the repo itself still exist?
let repoExists: boolean; let repoExists: boolean;
try { try {
@@ -76,7 +76,7 @@ export class GitHubRepository {
throw new AnonymousError( throw new AnonymousError(
repoExists ? "commit_not_found" : "repo_not_found", repoExists ? "commit_not_found" : "repo_not_found",
{ {
httpStatus: 404, httpStatus: repoExists ? 422 : 404,
cause: error as Error, cause: error as Error,
object: this, object: this,
} }