From 0d3038ffe93f41d4af3ea47da411a89369432339 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Wed, 24 Jun 2026 19:05:13 +0530 Subject: [PATCH] fix: use partial document for VCS disconnect updates --- .../Modules/Functions/Workers/Builds.php | 21 ++++++++++--------- .../Modules/VCS/Http/GitHub/Events/Create.php | 19 +++++++++-------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index cceb2630b1..d0806ccadf 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -298,7 +298,7 @@ class Builds extends Action try { $github->initializeVariables($providerInstallationId, $privateKey, $githubAppId); } catch (\Exception $e) { - if (\str_contains($e->getMessage(), 'Status: 404') + if ($e->getCode() === 404 && $resource->getAttribute('installationId', '') === $installationId) { $this->disconnectVcs($resource, $dbForProject, $dbForPlatform); } @@ -1569,15 +1569,16 @@ class Builds extends Action if (!empty($repositoryId)) { $dbForPlatform->deleteDocument('repositories', $repositoryId); } - $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), $resource - ->setAttribute('installationId', '') - ->setAttribute('installationInternalId', '') - ->setAttribute('providerRepositoryId', '') - ->setAttribute('providerBranch', '') - ->setAttribute('providerSilentMode', false) - ->setAttribute('providerRootDirectory', '') - ->setAttribute('repositoryId', '') - ->setAttribute('repositoryInternalId', '')); + $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), new Document([ + 'installationId' => '', + 'installationInternalId' => '', + 'providerRepositoryId' => '', + 'providerBranch' => '', + 'providerSilentMode' => false, + 'providerRootDirectory' => '', + 'repositoryId' => '', + 'repositoryInternalId' => '', + ])); } private function updateLatestDeployment(Database $dbForProject, Document $resource): Document 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 725779a969..53f67f34b0 100644 --- a/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Events/Create.php +++ b/src/Appwrite/Platform/Modules/VCS/Http/GitHub/Events/Create.php @@ -135,15 +135,16 @@ class Create extends Action $resources = $authorization->skip(fn () => $dbForProject->find($collection, $queries)); foreach ($resources as $resource) { - $authorization->skip(fn () => $dbForProject->updateDocument($collection, $resource->getId(), $resource - ->setAttribute('installationId', '') - ->setAttribute('installationInternalId', '') - ->setAttribute('providerRepositoryId', '') - ->setAttribute('providerBranch', '') - ->setAttribute('providerSilentMode', false) - ->setAttribute('providerRootDirectory', '') - ->setAttribute('repositoryId', '') - ->setAttribute('repositoryInternalId', ''))); + $authorization->skip(fn () => $dbForProject->updateDocument($collection, $resource->getId(), new Document([ + 'installationId' => '', + 'installationInternalId' => '', + 'providerRepositoryId' => '', + 'providerBranch' => '', + 'providerSilentMode' => false, + 'providerRootDirectory' => '', + 'repositoryId' => '', + 'repositoryInternalId' => '', + ]))); } $cursor = count($resources) === 1000 ? $resources[array_key_last($resources)] : null;