diff --git a/src/Appwrite/Realtime/Message/Handlers/AuthenticationHandler.php b/src/Appwrite/Realtime/Message/Handlers/AuthenticationHandler.php index b6d8616f0b..b17c672d91 100644 --- a/src/Appwrite/Realtime/Message/Handlers/AuthenticationHandler.php +++ b/src/Appwrite/Realtime/Message/Handlers/AuthenticationHandler.php @@ -24,7 +24,7 @@ class AuthenticationHandler extends Action $this ->desc('Authenticate the connection with a session token') ->label(Dispatcher::LABEL_MESSAGE_TYPE, 'authentication') - ->param('session', '', new Text(2048), 'Encoded session token') + ->param('session', '', new Text(2048), 'Encoded session token', optional: true) ->inject('connection') ->inject('realtime') ->inject('database') @@ -44,6 +44,10 @@ class AuthenticationHandler extends Action Registry $register, Response $response, ): array { + if ($session === '') { + throw new Exception(Exception::REALTIME_MESSAGE_FORMAT_INVALID, 'Payload is not valid.'); + } + $store = new Store(); $store->decode($session); diff --git a/tests/e2e/Services/Presence/PresenceRealtimeClientTest.php b/tests/e2e/Services/Presence/PresenceRealtimeClientTest.php index e03dba110d..26a28d9387 100644 --- a/tests/e2e/Services/Presence/PresenceRealtimeClientTest.php +++ b/tests/e2e/Services/Presence/PresenceRealtimeClientTest.php @@ -382,7 +382,7 @@ class PresenceRealtimeClientTest extends Scope ], ])); $missingStatus = $this->receiveErrorMessage($client); - $this->assertStringContainsString('status must be provided', $missingStatus['data']['message'] ?? ''); + $this->assertStringContainsString('status is required', $missingStatus['data']['message'] ?? ''); $this->assertQuietFor( $client, fn (array $frame): bool => ($frame['type'] ?? null) === 'event'