Merge pull request #12658 from appwrite/fix/vcs-github-webhook-500s

fix: prevent VCS webhook 500s on inaccessible commits and failed comment updates
This commit is contained in:
Torsten Dittmann authored and GitHub committed 2026-06-23 17:50:05 +04:00
commit d046b4b87b
2 files changed
+13 -1

No files matched your search

@@ -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));
}
@@ -8,6 +8,7 @@ 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;
@@ -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"] ?? '';