From 891ba49e09af391700ef862113ee8e652afb6f09 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Tue, 15 Sep 2026 12:25:09 +0530 Subject: [PATCH] fix(router): link function build errors to function deployments The build failed, canceled and not-ready pages always linked to the sites console, so a function domain whose deployment was not ready sent users to a site that does not exist. Function links now use the functions shape: legacy .../functions/function-{id}[/deployment-{deploymentId}] and root /projects/{projectId}/functions/{id}[/deployments/{deploymentId}]. --- app/controllers/general.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 40a0751174..b8580aa742 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -357,12 +357,15 @@ function router(Http $utopia, Database $dbForPlatform, callable $getProjectDB, S $status = $deployment->getAttribute('status'); $region = $project->getAttribute('region', 'default'); $legacyConsolePaths = System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root'; - $siteUrl = $legacyConsolePaths - ? "/console/project-{$region}-{$project->getId()}/sites/site-{$resource->getId()}" - : "/projects/{$project->getId()}/sites/{$resource->getId()}"; + $collection = $type === 'function' ? 'functions' : 'sites'; + $resourceUrl = $legacyConsolePaths + ? "/console/project-{$region}-{$project->getId()}/{$collection}/{$type}-{$resource->getId()}" + : "/projects/{$project->getId()}/{$collection}/{$resource->getId()}"; + // Function deployments are listed on the function page itself + $deploymentsUrl = $type === 'function' ? $resourceUrl : "{$resourceUrl}/deployments"; $deploymentUrl = $legacyConsolePaths - ? "{$siteUrl}/deployments/deployment-{$deployment->getId()}" - : "{$siteUrl}/deployments/{$deployment->getId()}"; + ? "{$deploymentsUrl}/deployment-{$deployment->getId()}" + : "{$resourceUrl}/deployments/{$deployment->getId()}"; switch ($status) { case 'failed': @@ -371,7 +374,7 @@ function router(Http $utopia, Database $dbForPlatform, callable $getProjectDB, S break; case 'canceled': $exception = new AppwriteException(AppwriteException::BUILD_CANCELED, view: $errorView); - $exception->addCTA('View deployments', $url . $siteUrl . '/deployments'); + $exception->addCTA('View deployments', $url . $deploymentsUrl); break; default: $exception = new AppwriteException(AppwriteException::BUILD_NOT_READY, view: $errorView);