-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Description
Bug Report
Summary
Typo3Integration::processEvent() calls $request->getUri()->__toString() without handling the case where the URI is null. In CLI/cron context, certain TYPO3 extensions (e.g. codingms/openimmo) create a fake ServerRequest with applicationType=BE but without a URI set. This causes a TypeError that masks the original error Sentry is trying to report.
Steps to Reproduce
- Run a TYPO3 scheduler task that sets
$GLOBALS['TYPO3_REQUEST']to aServerRequestwithout URI but withapplicationType=BE:
->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_BE)
->withAttribute('site', $site);
- Trigger any error during the task execution
- Sentry's
SentryLogWriterpicks up the log entry and callsTypo3Integration::processEvent() processEvent()detectsisBackend() === trueand callssetUrl()setUrl()calls$request->getUri()->__toString() → getUri()returns null → TypeError
Expected Behavior
Sentry should gracefully handle a missing URI and either skip the URL enrichment or tag the event as cli.
Actual Behavior
TypeError: TYPO3\CMS\Core\Http\Request::getUri(): Return value must be of type
Psr\Http\Message\UriInterface, null returned
in vendor/typo3/cms-core/Classes/Http/Request.php:287
Stack trace:
#0 Typo3Integration.php(63): Request->getUri()
#1 Typo3Integration.php(46): setUrl()
#2 Typo3Integration.php(31): processEvent()
#3 Scope.php(468): {closure}()
...
#10 SentryLogWriter.php(55): Client::captureMessage()
Suggested Fix
Add a try-catch in setUrl() or check for CLI context in processEvent():
private function processEvent(Event $event): void
{
$request = $this->getServerRequest();
if ($request instanceof ServerRequestInterface) {
try {
if (ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend()) {
$event->setTag('request_type', 'frontend');
$this->setUrl($event, $request);
} elseif (ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend()) {
$event->setTag('request_type', 'backend');
$this->setUrl($event, $request);
}
} catch (\TypeError) {
if (Environment::isCli()) {
$event->setTag('request_type', 'cli');
}
}
} elseif (Environment::isCli()) {
$event->setTag('request_type', 'cli');
}
// ...
}Environment
- networkteam/sentry-client: 5.2.1
- TYPO3: 13.x
- PHP: 8.3+
- Context: CLI/Scheduler with codingms/openimmo ImportCommand
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels