TR-7703 Port improved exception-split regex from evp/lib-application-logging-bundle (3.x line) - #27
Conversation
…bundle Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request updates the ExceptionMessageParser to use an improved regular expression (/^(.*?[Ee]xception.*?) in \//) matching the canonical parser in evp/lib-application-logging-bundle. This ensures exception-shaped messages are split correctly at the first file path delimiter ( in /) rather than generic words like "in" or SQL IN operators. The changes also include updated documentation in the README and CHANGELOG, along with comprehensive unit tests to validate the new regex behavior. No review comments were provided, and the implementation looks solid.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Task
TR-7703: Port improved exception-split regex from evp/lib-application-logging-bundle to paysera/lib-logging-extra-bundle (3.x line)
https://jira.paysera.net/browse/TR-7703
Summary of Changes
src/Service/ExceptionMessageParser.php— replaced the split pattern/^(.*?:?.*?exception.*?) in /iwith the canonical/^(.*?[Ee]xception.*?) in \//, so both logging bundles split exception-shaped messages identically. The shortmessageis now cut at the firstin /file path instead of the first word "in": tails likein state NEW,in driver: ...and SQLIN (...)stay in the headline (previously e.g. everyAn exception occurred in driver: ...collapsed toAn exception occurred).Exceptionmatches with a capitalized or lowercase first letter, and the delimiter stays case-sensitive soIN /...fragments are not split points. The pattern is verbatim from the canonical parser inevp/lib-application-logging-bundle8.9.1/7.9.1 (src/Service/ExceptionMessageParser.phpat tag8.9.1:preg_match('/^(.*?[Ee]xception.*?) in \\//', strtr($message, ...))) — the class docblock now documents that identity instead of the former deliberate divergence.tests/Unit/Service/ExceptionMessageParserTest.php— ported the verification set from the canonical bundle's review (13 synthetic cases + real production message shapes): 10 new data-provider cases (word "in" inside the reason, SQLIN (1,2),IN /*hint*/,IN /etc, chained exception with stack traces,in driver:without a file path → unsplit, Symfonyat ... lineone-liner → unsplit, prose mentioning an*Exception*class → unsplit, exception without a path → unsplit, file-and-line locus) and 1 updated case (lowercase natural-language exception now uses a real/-path; a barein SomeClasstail no longer splits by design). 21 parser cases total.CHANGELOG.md—3.4.1entry underFixed(patch release, mirroring the canonical bundle's 8.9.1/7.9.1 patch releases for the same change).README.md— the split-behavior paragraph now describes thein /anchor and canonical parity instead of the removed case-insensitive divergence.Test Plan
Prerequisites
composer install).Steps to Test
bin/phpunit tests/Unit/Service/ExceptionMessageParserTest.phpbin/phpunit tests/Unit/Service/Formatter/StdoutJsonFormatterTest.phpmessage/full_messagesplitting throughStdoutRecordEncoderunchanged for path-anchored messages.bin/phpunitexample/test.php, real MonologBundle + this bundle): log'An exception occurred in driver: SQLSTATE[HY000] [2006] MySQL server has gone away'at error level.messageand emits nofull_message(before this change,messagecollapsed toAn exception occurred).Expected Results
/-prefixed file path after the exception text are split into shortmessage+ rawfull_message, identically toevp/lib-application-logging-bundle≥ 8.9.1 / 7.9.1.in state NEW,in driver: ...,IN (...),IN /etc) keep those tails in the headline or stay unsplit entirely when no file path is present./-prefixed path (including prose that merely mentions an*Exception*class) are no longer split and emit nofull_message.Closes TR-7703
🤖 Generated with Claude Code