Skip to content

TR-7703 Port improved exception-split regex from evp/lib-application-logging-bundle (3.x line) - #27

Merged
mSprunskas merged 1 commit into
paysera:masterfrom
sanchowsk:feature/TR-7703-port-improved-exception-split-regex
Jul 16, 2026
Merged

TR-7703 Port improved exception-split regex from evp/lib-application-logging-bundle (3.x line)#27
mSprunskas merged 1 commit into
paysera:masterfrom
sanchowsk:feature/TR-7703-port-improved-exception-split-regex

Conversation

@sanchowsk

Copy link
Copy Markdown

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 /i with the canonical /^(.*?[Ee]xception.*?) in \//, so both logging bundles split exception-shaped messages identically. The short message is now cut at the first in / file path instead of the first word "in": tails like in state NEW, in driver: ... and SQL IN (...) stay in the headline (previously e.g. every An exception occurred in driver: ... collapsed to An exception occurred). Exception matches with a capitalized or lowercase first letter, and the delimiter stays case-sensitive so IN /... fragments are not split points. The pattern is verbatim from the canonical parser in evp/lib-application-logging-bundle 8.9.1/7.9.1 (src/Service/ExceptionMessageParser.php at tag 8.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, SQL IN (1,2), IN /*hint*/, IN /etc, chained exception with stack traces, in driver: without a file path → unsplit, Symfony at ... line one-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 bare in SomeClass tail no longer splits by design). 21 parser cases total.
  • CHANGELOG.md3.4.1 entry under Fixed (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 the in / anchor and canonical parity instead of the removed case-insensitive divergence.

Test Plan

Prerequisites

  • PHP 7.4+ with dev dependencies installed (composer install).

Steps to Test

  1. Run the parser unit suite: bin/phpunit tests/Unit/Service/ExceptionMessageParserTest.php
    • Expected: 21 tests / 21 assertions green, including the regression cases above.
  2. Run the consumer-chain suite: bin/phpunit tests/Unit/Service/Formatter/StdoutJsonFormatterTest.php
    • Expected: 23 tests / 75 assertions green — message / full_message splitting through StdoutRecordEncoder unchanged for path-anchored messages.
  3. Run the full suite: bin/phpunit
    • Expected: 91 tests / 1287 assertions green.
  4. Optional runtime spot-check via the shipped example kernel (example/test.php, real MonologBundle + this bundle): log 'An exception occurred in driver: SQLSTATE[HY000] [2006] MySQL server has gone away' at error level.
    • Expected: the stdout JSON line keeps the full text in message and emits no full_message (before this change, message collapsed to An exception occurred).

Expected Results

  • Messages with a /-prefixed file path after the exception text are split into short message + raw full_message, identically to evp/lib-application-logging-bundle ≥ 8.9.1 / 7.9.1.
  • Messages whose only "in" tails are prose/SQL (in state NEW, in driver: ..., IN (...), IN /etc) keep those tails in the headline or stay unsplit entirely when no file path is present.
  • Behavior note (intended): messages without a /-prefixed path (including prose that merely mentions an *Exception* class) are no longer split and emit no full_message.

Closes TR-7703

🤖 Generated with Claude Code

…bundle

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mSprunskas
mSprunskas merged commit 39fc09b into paysera:master Jul 16, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants