FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Stop leaking handler exception messages to the client · modelcontextprotocol/php-sdk@e44dcf9 · GitHub

Repository navigation

Commit e44dcf9

Browse files
committed
Stop leaking handler exception messages to the client
1 parent 8ad14b3 commit e44dcf9

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

‎src/Server/Protocol.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ private function handleRequest(TransportInterface $transport, Request $request,
313313
} catch (\Throwable $e) {
314314
$this->logger->error(\sprintf('Uncaught exception: %s', $e->getMessage()), ['exception' => $e]);
315315

316-
$error = Error::forInternalError($e->getMessage(), $request->getId());
316+
$error = Error::forInternalError(self::INTERNAL_ERROR_MESSAGE, $request->getId());
317317
$errorEvent = $this->dispatchEvent(new ErrorEvent($error, $request, $session, $e));
318318
$error = $errorEvent->getError();
319319

‎tests/Unit/Server/ProtocolTest.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,8 @@ public function testHandlerUnexpectedExceptionReturnsInternalError(): void
670670
$message = json_decode($outgoing[0]['message'], true);
671671
$this->assertArrayHasKey('error', $message);
672672
$this->assertEquals(Error::INTERNAL_ERROR, $message['error']['code']);
673-
$this->assertStringContainsString('Unexpected error', $message['error']['message']);
673+
$this->assertSame('Internal server error.', $message['error']['message']);
674+
$this->assertStringNotContainsString('Unexpected error', $message['error']['message']);
674675
}
675676

676677
#[TestDox('Notification handler exceptions are caught and logged')]

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL