fix: ignore non-object exception context in GroupExceptionsProcessor - #28
Open
artem-yakymchuk-paysera wants to merge 1 commit into
Conversation
get_class() was called on context['exception'] unguarded, so any logger call passing a string there (e.g. ['exception' => $e->getMessage()]) threw a TypeError from inside the logging call and the exception propagated to the caller. Non-object values are now ignored: the record passes through unchanged and no Sentry fingerprint grouping is applied. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012cBCgqnh2hwmR74Ngw8TEi
siarhei-kruk
approved these changes
Aug 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
GroupExceptionsProcessor(taggedmonolog.processorfor the Sentry handler, which runs at ERROR level in our services) callsget_class($record->context['exception'])with no guard. Any log call that passes a non-object there — e.g.$logger->error('...', ['exception' => $e->getMessage()]), a string — throws aTypeErrorfrom inside the logger call, and since Monolog installs no exception handler it propagates to the caller. In one consumer this crashed whole Kafka batch processing runs.Fix
Ignore non-object
context['exception']values in both class variants (Monolog v3 and v1/v2): the record passes through unchanged and no Sentry fingerprint grouping is applied. Grouping behaviour for real Throwables is unchanged.Tests
New
GroupExceptionsProcessorTest(uses the sharedMonologRecordTrait, so it covers both Monolog branches across the CI matrix):exceptioncontext → record unchanged, no throw, no fingerprintexceptioncontext → untouchedFull suite: 142 tests OK locally (PHP 8.2, Monolog v3).
Changelog entry added under 3.5.1.
🤖 Generated with Claude Code
https://claude.ai/code/session_012cBCgqnh2hwmR74Ngw8TEi