Merge pull request #11809 from appwrite/codex/fix-console-null-route

[codex] Handle null console routes in API middleware
This commit is contained in:
Chirag Aggarwal
2026-04-07 14:42:08 +05:30
committed by GitHub
2 changed files with 15 additions and 0 deletions
+7
View File
@@ -98,6 +98,9 @@ Http::init()
->inject('authorization')
->action(function (Http $utopia, Request $request, Database $dbForPlatform, Database $dbForProject, Audit $queueForAudits, Document $project, User $user, ?Document $session, array $servers, string $mode, Document $team, ?Key $apiKey, Authorization $authorization) {
$route = $utopia->getRoute();
if ($route === null) {
throw new AppwriteException(AppwriteException::GENERAL_ROUTE_NOT_FOUND);
}
/**
* Handle user authentication and session validation.
@@ -489,6 +492,10 @@ Http::init()
$request->setUser($user);
$route = $utopia->getRoute();
if ($route === null) {
throw new AppwriteException(AppwriteException::GENERAL_ROUTE_NOT_FOUND);
}
$path = $route->getMatchedPath();
$databaseType = match (true) {
str_contains($path, '/documentsdb') => DATABASE_TYPE_DOCUMENTSDB,
+8
View File
@@ -122,6 +122,14 @@ class HTTPTest extends Scope
$this->assertEquals(200, $response['headers']['status-code']);
}
public function testConsoleRootWithoutRouteDoesNotFatal()
{
$response = $this->client->call(Client::METHOD_GET, '/console/', $this->getHeaders());
$this->assertEquals(404, $response['headers']['status-code']);
$this->assertEquals('general_route_not_found', $response['body']['type']);
}
public function testCors()
{