fix: address critical review findings — MergeGuard/Metrics wiring, sort NaN, conflict bypass, DRY errors
C1: Wire MergeGuard into maybeMergePullRequest (processor.ts)
C2: Wire MetricsCollector.recordMergeAttempt into merge path
C3: Wire isAlreadyMergedError from github/errors.ts (shared)
C4: Fix sort comparator NaN in markReviewCheckApproved
C5: Guard conflict resolution behind !disposition.requiresAdminApproval
C6: Extract isNotFoundError + isAlreadyMergedError to github/errors.ts
Remove 3 duplicated local copies (chat/processor, webhook/processor, processor.ts)
R1: Create shared github/errors.ts for production code
Docs: audit-v2-final.md, critical-review-v2.md, report-v2.html, workflow_status.md
Skill: .claude/skills/ghbot-workflow/SKILL.md
This commit is contained in:
1 parent
78bf8e9e41
commit
c8a32b6251
9 files changed
+2238
-39
No files matched your search
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Shared GitHub API error utilities.
|
||||
*/
|
||||
|
||||
export function isNotFoundError(error: unknown): boolean {
|
||||
return typeof error === "object" && error !== null && "status" in error && error.status === 404;
|
||||
}
|
||||
|
||||
export function isAlreadyMergedError(error: unknown): boolean {
|
||||
if (typeof error !== "object" || error === null || !("status" in error)) {
|
||||
return false;
|
||||
}
|
||||
const candidate = error as { status?: unknown; message?: unknown };
|
||||
if (candidate.status !== 405 && candidate.status !== 409) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
typeof candidate.message === "string" &&
|
||||
/already.{0,20}merged|Pull Request is not mergeable/i.test(candidate.message)
|
||||
);
|
||||
}
|
||||
|
||||
export function isRetryableGitHubError(error: unknown): boolean {
|
||||
if (typeof error !== "object" || error === null) {
|
||||
return false;
|
||||
}
|
||||
const candidate = error as { status?: unknown };
|
||||
if (typeof candidate.status === "number") {
|
||||
if (candidate.status === 429) return true;
|
||||
if (candidate.status >= 500 && candidate.status < 600) return true;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Reference in new issue
Block a user