Skip to content

Feature/java stacktrace exception values#45

Open
DiscountDarcy wants to merge 10 commits into
coldbox-modules:developmentfrom
inLeague:feature/java-stacktrace-exception-values
Open

Feature/java stacktrace exception values#45
DiscountDarcy wants to merge 10 commits into
coldbox-modules:developmentfrom
inLeague:feature/java-stacktrace-exception-values

Conversation

@DiscountDarcy

@DiscountDarcy DiscountDarcy commented Jul 13, 2026

Copy link
Copy Markdown

Description

Fix existing boxlang text failures and add support to capture the Java stacktrace as well as the CF stacktrace. Adds tests for java stacktrace support.

Issues

#43
#44

Type of change

Please delete options that are not relevant.

  • Bug Fix
  • New Feature

Checklist

  • My code follows the style guidelines of this project cfformat
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Karlin [bot] added 9 commits July 13, 2026 09:36
… events

When showJavaStackTrace=true, the Java stack trace is now parsed into
structured Sentry exception values with proper frames (function, filename,
lineno, in_app) instead of being dumped as a raw text blob in 'extra'.

This gives Sentry proper structured frames for the Java side of the call
stack, enabling:
- Frame-by-frame navigation in the Sentry UI
- Proper exception chaining via 'Caused by:' parsing
- Correct grouping and deduplication
- in_app heuristics for application vs framework frames

The parseJavaStackTrace() method handles:
- Standard 'at package.Class.method(File.java:line)' frames
- 'Native Method' and 'Unknown Source' frames (no line number)
- 'Caused by:' nested exception chains
- '... N more' truncated frame indicators

Also includes:
- Null-safety fix for structifyObject() (from inleague-api patch)
- Deprecation of removeTabsOnJavaStackTrace parameter
- 7 new test cases covering parsing, in_app detection, Caused by chains,
  empty TagContext fallback, and edge cases
- Add \r stripping before splitting by \n (regression from old code)
- Add jakarta. to in_app exclusion list (Jakarta EE classes)
- Add Suppressed: exception handling (Java 7+ suppressed exceptions)
- These fix medium-priority issues from code review
… of regex

BoxLang's regex engine doesn't handle non-greedy quantifiers and complex
patterns reliably. Rewrote parseJavaStackTrace() to use find(), mid(),
left() and simple string operations for parsing.

This fixes all 5 test failures:
- Exception type was including the message (regex not splitting on colon)
- Frames array was empty (at-pattern regex not matching)
- Caused by chains only producing 2 exceptions instead of 3
- Suppressed exceptions not being parsed

Also fixes the upstream test failures caused by BoxLang incompatibility
with the old regex-based approach.
BoxLang's reFindNoCase doesn't handle complex regex patterns reliably.
Replaced with simple left() prefix checks against a list of framework
packages. More readable and guaranteed to work across engines.
1. 'can log Java exception': Use null-safe operator for e.message which
   is null when catching Java exceptions on both BoxLang and Lucee

2. 'can log exception with no tagContext': Replace 'for (var key in e)'
   iteration with duplicate()+structDelete() which works on all engines.
   BoxLang exceptions don't support key iteration like Lucee/ACF.
1. Make prefix checks include the colon: 'Caused by:' and 'Suppressed:'
   instead of 'Caused by' and 'Suppressed'
2. Simplify last-dot iteration with listToArray/arrayToList instead of
   manual character loop
3. Fix indentation after removing the if(lastDot>1) block

@jclausen jclausen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some concerns on this one, I would like to see addressed.

Comment thread models/SentryService.cfc Outdated
// If showJavaStackTrace is enabled, parse the Java stack trace and add it
// as a second (or more) entry in exception.values. This gives Sentry proper
// structured frames for the Java side instead of a raw text blob in "extra".
if ( arguments.showJavaStackTrace && len( arguments.exception.StackTrace ) ) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think we need the overhead of this if the tagContext is available. ( e.g. the arguments.exception.TagContext is not empty.

Comment thread models/SentryService.cfc Outdated
}

// "Caused by: ..." — save current exception, start a new one
if ( left( trimmedLine, 10 ) == "Caused by:" ) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI has, effectively, put the same code in each conditional, with the only difference being the prefix. Maybe we could consolidate this - or at least the duplicated code - in to a separate function?

1. Gate Java stack trace parsing on TagContext being empty — no need
   for the overhead when CFML frames are already available
2. Extract duplicated 'Caused by:'/'Suppressed:' parsing into
   _parseExceptionPrefix() helper function
3. Add test verifying Java traces are skipped when TagContext is present
4. Add .gitignore entries for local server test configs
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.

2 participants