Merge pull request #13017 from appwrite/fix/vcs-installation-region-check

fix(vcs): scope region check to project DB access on installation deleted
This commit is contained in:
Harsh Mahajan authored and GitHub committed 2026-07-28 13:08:54 +05:30
commit 6a63947c92
1 file changed
+22 -1
@@ -8,13 +8,16 @@ use Appwrite\Platform\Modules\VCS\Http\GitHub\Deployment;
use Appwrite\Utopia\Request;
use Appwrite\Utopia\Response;
use Appwrite\Vcs\Factory as VcsFactory;
use Utopia\Config\Config;
use Utopia\Console;
use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\Database\Query;
use Utopia\Database\Validator\Authorization;
use Utopia\DSN\DSN;
use Utopia\Platform\Scope\HTTP;
use Utopia\Span\Span;
use Utopia\System\System;
use Utopia\VCS\Adapter\Git\GitHub;
class Create extends Action
@@ -121,7 +124,7 @@ class Create extends Action
$projectId = $installation->getAttribute('projectId', '');
$project = $authorization->skip(fn () => $dbForPlatform->getDocument('projects', $projectId));
if (!$project->isEmpty()) {
if (!$project->isEmpty() && $this->isProjectInCurrentRegion($project)) {
$dbForProject = $getProjectDB($project);
foreach (['functions', 'sites'] as $collection) {
@@ -179,6 +182,24 @@ class Create extends Action
} while ($installationCursor !== null);
}
private function isProjectInCurrentRegion(Document $project): bool
{
try {
$dsn = new DSN($project->getAttribute('database'));
$databaseName = $dsn->getHost();
} catch (\InvalidArgumentException) {
$databaseName = $project->getAttribute('database');
}
$databases = Config::getParam('pools-database', []);
if (!\in_array($databaseName, $databases)) {
Console::warning("Skipping project {$project->getId()}: database '{$databaseName}' is not part of region " . System::getEnv('_APP_REGION'));
return false;
}
return true;
}
private function handlePushEvent(
array $parsedPayload,
VcsFactory $vcsFactory,