From 2eb5aca116c2fecb19925eb4a53007829a22de2a Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Fri, 22 May 2026 17:58:14 +0100 Subject: [PATCH] Accept _APP_MIGRATION_HOST too when matching local source endpoint _APP_DOMAIN is the public host users paste from console, but programmatic migrations that leave `endpoint` blank default to _APP_MIGRATION_HOST in processMigration. Both are valid references to this cluster; checking only _APP_DOMAIN rejected the second pattern (e.g. CI tests pass the internal host directly) and routed legitimate intra-cluster migrations to SDK. --- src/Appwrite/Platform/Workers/Migrations.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index d73b72c503..1ca9b5ad90 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -208,12 +208,18 @@ class Migrations extends Action $this->sourceProject = $this->dbForPlatform->getDocument('projects', $credentials['projectId']); // Same projectId on source and destination only means "local" when the source - // endpoint's host is this installation — otherwise it's an external Appwrite - // that happens to share an id, and we must go over SDK/HTTP. + // endpoint's host is one of this installation's hostnames — _APP_DOMAIN is the + // public host users paste from console; _APP_MIGRATION_HOST is the internal one + // workers default to when the caller omits `endpoint`. Anything else is an + // external Appwrite that happens to share an id, and we must go over SDK/HTTP. $sourceHost = parse_url($credentials['endpoint'] ?? '', PHP_URL_HOST); $localDomain = System::getEnv('_APP_DOMAIN', ''); - $isLocalEndpoint = is_string($sourceHost) && $localDomain !== '' - && ($sourceHost === $localDomain || str_ends_with($sourceHost, '.' . $localDomain)); + $migrationHost = System::getEnv('_APP_MIGRATION_HOST', ''); + + $matchesDomain = $localDomain !== '' + && ($sourceHost === $localDomain || str_ends_with((string) $sourceHost, '.' . $localDomain)); + $matchesInternal = $migrationHost !== '' && $sourceHost === $migrationHost; + $isLocalEndpoint = is_string($sourceHost) && ($matchesDomain || $matchesInternal); $isLocalSource = !$this->sourceProject->isEmpty() && (!$isAppwriteToAppwrite || $isLocalEndpoint);