From 2d1d290c9bd58bf61a88e3e5c698f7fd758f641b Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Tue, 23 Jun 2026 17:58:25 +0530 Subject: [PATCH 1/2] fix: prevent VCS webhook 500s on inaccessible commits and failed comment updates - Wrap getCommit() in try/catch so force-pushed/deleted commits fall back to empty author/message instead of throwing a 500 - Catch updateComment() failures at all 3 call sites so a cosmetic PR comment update failure no longer fails the entire deployment --- .../Platform/Modules/VCS/Http/GitHub/Deployment.php | 6 ++++++ .../Platform/Modules/VCS/Http/GitHub/Events/Create.php | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Deployment.php b/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Deployment.php index d172fdc688..d312cc3a56 100644 --- a/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Deployment.php +++ b/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Deployment.php @@ -237,6 +237,8 @@ trait Deployment $comment->addBuild($project, $resource, $resourceType, $commentStatus, $deploymentId, $action, $commentPreviewUrl); $latestCommentId = \strval($github->updateComment($owner, $repositoryName, $latestCommentId, $comment->generateComment())); + } catch (\Throwable $e) { + Console::warning("Failed to update PR comment '{$latestCommentId}': " . $e->getMessage()); } finally { $authorization->skip(fn () => $dbForPlatform->deleteDocument('vcsCommentLocks', $latestCommentId)); } @@ -308,6 +310,8 @@ trait Deployment $comment->addBuild($project, $resource, $resourceType, $commentStatus, $deploymentId, $action, ''); $latestCommentId = \strval($github->updateComment($owner, $repositoryName, $latestCommentId, $comment->generateComment())); + } catch (\Throwable $e) { + Console::warning("Failed to update PR comment '{$latestCommentId}': " . $e->getMessage()); } finally { $authorization->skip(fn () => $dbForPlatform->deleteDocument('vcsCommentLocks', $latestCommentId)); } @@ -526,6 +530,8 @@ trait Deployment $comment->addBuild($project, $resource, $resourceType, $commentStatus, $deploymentId, $action, $previewUrl); $github->updateComment($owner, $repositoryName, $latestCommentId, $comment->generateComment()); } + } catch (\Throwable $e) { + Console::warning("Failed to update PR comment '{$latestCommentId}': " . $e->getMessage()); } finally { $authorization->skip(fn () => $dbForPlatform->deleteDocument('vcsCommentLocks', $latestCommentId)); } diff --git a/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Events/Create.php b/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Events/Create.php index 420715ddc6..5ace6d72df 100644 --- a/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Events/Create.php +++ b/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Events/Create.php @@ -12,6 +12,7 @@ use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Query; use Utopia\Database\Validator\Authorization; +use Utopia\Console; use Utopia\Platform\Scope\HTTP; use Utopia\Span\Span; use Utopia\System\System; @@ -207,7 +208,12 @@ class Create extends Action $github->initializeVariables($providerInstallationId, $privateKey, $githubAppId); - $commitDetails = $github->getCommit($providerRepositoryOwner, $providerRepositoryName, $providerCommitHash); + try { + $commitDetails = $github->getCommit($providerRepositoryOwner, $providerRepositoryName, $providerCommitHash); + } catch (\Throwable $e) { + Console::warning("Failed to fetch commit '{$providerCommitHash}': " . $e->getMessage()); + $commitDetails = []; + } $providerCommitAuthor = $commitDetails["commitAuthor"] ?? ''; $providerCommitMessage = $commitDetails["commitMessage"] ?? ''; From de1951996e84bfe9bf1a876b0a2d432699953ca6 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Tue, 23 Jun 2026 18:43:05 +0530 Subject: [PATCH 2/2] fix: order use imports --- src/Appwrite/Platform/Modules/VCS/Http/GitHub/Events/Create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Events/Create.php b/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Events/Create.php index 5ace6d72df..e40e447ed5 100644 --- a/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Events/Create.php +++ b/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Events/Create.php @@ -8,11 +8,11 @@ use Appwrite\Platform\Action; use Appwrite\Platform\Modules\VCS\Http\GitHub\Deployment; use Appwrite\Utopia\Request; use Appwrite\Utopia\Response; +use Utopia\Console; use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Query; use Utopia\Database\Validator\Authorization; -use Utopia\Console; use Utopia\Platform\Scope\HTTP; use Utopia\Span\Span; use Utopia\System\System;