Skip to content

fix(detect_exceptions): replace catch-all rule with targeted patterns for JavaException - #305

Open
vparfonov wants to merge 1 commit into
ViaQ:v0.47.0-rhfrom
vparfonov:log9963-v0.47.0-rh
Open

fix(detect_exceptions): replace catch-all rule with targeted patterns for JavaException#305
vparfonov wants to merge 1 commit into
ViaQ:v0.47.0-rhfrom
vparfonov:log9963-v0.47.0-rh

Conversation

@vparfonov

@vparfonov vparfonov commented Sep 1, 2026

Copy link
Copy Markdown

Summary

Fix incorrect multiline exception detection that merges independent JSON log records (LOG-9963) while maintaining support for legitimate multi-line exceptions including Java exceptions with non-indented continuation lines like Oracle ORA errors (LOG-9995).

Problem

The detect_exceptions transform was using a bounded catch-all regex pattern ^.+$ to match continuation lines of Java exceptions. While bounded (max 2 lines), this pattern was still too greedy and would match ANY non-empty line after an exception keyword, causing independent log records to be incorrectly merged into a single event.

Example of the bug:

java.lang.RuntimeException: something went wrong    ← matches exception keyword
first continuation line without stack trace         ← matches ^.+$, merged
second continuation line without stack trace        ← matches ^.+$, merged
third unrelated message                             ← stops here (limit reached)

Result: 3 independent messages merged into 1 event

Solution

Replace the generic catch-all with 3 targeted continuation patterns that:

  1. Handle legitimate multi-line scenarios (ORA errors, error codes, parenthetical continuations)
  2. Prevent merger of arbitrary text/JSON messages

New patterns:

  • ^[A-Z]+-?\d+ — Oracle ORA errors, DB error codes (e.g., ORA-12521)
  • ^[\t ]*\( — Parenthetical continuations (e.g., CONNECTION_ID)
  • ^[\t ]+\S— Indented lines (standard stack frames)

These fire from both JavaAfterException and JavaContinuation states, allowing proper chaining through the state machine while being selective about what gets merged.

Fixes

  • LOG-9963: Independent log records with exception keywords no longer incorrectly merged (and LOG-9998)
  • Maintains LOG-9995 support: ORA errors and other error codes properly grouped via targeted patterns instead of catch-all

… (LOG-9963, LOG-9995)

Fix incorrect multiline exception detection that was merging independent log
records. Replace bounded catch-all pattern (^.+$) with 3 targeted patterns:
- ^[A-Z]+-?\d+       : Oracle ORA errors, DB error codes
- ^[\t ]*\(          : Parenthetical continuations
- ^[\t ]+\S          : Indented lines

This allows proper grouping of legitimate multi-line exceptions (stack traces,
ORA error codes, nested exceptions) while preventing merger of independent
JSON log records with exception keywords (LOG-9963).

Fixes LOG-9963, LOG-9995

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Signed-off-by: Vitalii Parfonov <vparfono@redhat.com>
@openshift-ci
openshift-ci Bot requested review from Clee2691 and jcantrill September 1, 2026 20:24
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: f8c052ce-f01f-4744-ae3c-3188869d0be2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@vparfonov

Copy link
Copy Markdown
Author

/assign @jcantrill
/cc @Clee2691

@vparfonov vparfonov changed the title fix(detect_exceptions): replace catch-all rule with targeted patterns… fix(detect_exceptions): replace catch-all rule with targeted patterns for JavaException Sep 1, 2026
@vparfonov

Copy link
Copy Markdown
Author

/retest-required

@jcantrill jcantrill added the v0.47 label Sep 2, 2026
@jcantrill

Copy link
Copy Markdown
Member

/approve
/lgtm

@openshift-ci openshift-ci Bot added the lgtm label Sep 2, 2026
@openshift-ci

openshift-ci Bot commented Sep 2, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jcantrill, vparfonov

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved label Sep 2, 2026
@jcantrill

Copy link
Copy Markdown
Member

/label verified

✅ VERIFICATION RESULT: FIX CONFIRMED

Critical Evidence:

WITH detectMultilineException filter active, the 3 independent JSON logs were received as 3 SEPARATE events:

1. Seq 1788899176851723471: {"timestamp":"2026-09-08T20:00:00Z","level":"ERROR","message":"Request failed with java.lang.Throwable: connection timeout","requestId":"680"...}
2. Seq 1788899176853720751: {"timestamp":"2026-09-08T20:00:01Z","level":"INFO","message":"Processing next request","requestId":"681"...}
3. Seq 1788899176853796374: {"timestamp":"2026-09-08T20:00:02Z","level":"INFO","message":"Request completed successfully","requestId":"682"...}

Key Findings:
- Each has a unique openshift.sequence number confirming they're distinct events
- The first log contains java.lang.Throwable which triggers exception detection
- The logs were NOT merged despite the exception keyword
- This matches the expected behavior after the fix

Summary

┌───────────────────┬────────────────────────────────┐
│      Metric       │             Value              │
├───────────────────┼────────────────────────────────┤
│ Cluster           │ OpenShift (cluster-admin)      │
├───────────────────┼────────────────────────────────┤
│ OpenShift Logging │ 6.6.0                          │
├───────────────────┼────────────────────────────────┤
│ Vector Version    │ 0.54.0                         │
├───────────────────┼────────────────────────────────┤
│ PR Target         │ v0.47.0-rh (for Logging 6.5.z) │
├───────────────────┼────────────────────────────────┤
│ Test Result       │ ✅ PASS - No incorrect merging │
└───────────────────┴────────────────────────────────┘

The fix (replacing catch-all ^.+$ pattern with targeted patterns) is effective endent JSON logs remain separate even when the first contains an exceptionkeyword.

@openshift-ci openshift-ci Bot added the verified label Sep 9, 2026
@vparfonov

Copy link
Copy Markdown
Author

/retest-required

@jcantrill

Copy link
Copy Markdown
Member

/test clo-functional

@openshift-ci

openshift-ci Bot commented Sep 9, 2026

Copy link
Copy Markdown

@vparfonov: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/clo-functional 3cce194 link unknown /test clo-functional

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants