Preserve root exception when bulk scheduling fails in BulkManagement/MassSchedule - #270
Open
ddevallan wants to merge 1 commit into
Open
Preserve root exception when bulk scheduling fails in BulkManagement/MassSchedule#270ddevallan wants to merge 1 commit into
ddevallan wants to merge 1 commit into
Conversation
…MassSchedule BulkManagement::scheduleBulk() caught all exceptions, logged only the message, and returned false — discarding the exception object entirely. MassSchedule::publishMass() then threw a new LocalizedException with no previous exception attached, making the root cause invisible to callers, error monitoring tools, and exception chain walkers. Added getLastException() to BulkManagement to expose the last caught exception. MassSchedule now retrieves it and passes it as the previous exception to LocalizedException, preserving the full chain for debugging.
marcelmtz
approved these changes
Jun 9, 2026
marcelmtz
left a comment
Contributor
There was a problem hiding this comment.
This is really cool, thank you! @thebraziliandeveloper qq. Does it make sense to clear the last exception in the scheduleBulk? 🤔
$this->lastException = null
Member
|
@ddevallan Any thoughts on Marcel's question above? Thanks |
Member
|
Fable assessment:
Not merging yet |
marcelmtz
requested changes
Aug 17, 2026
marcelmtz
left a comment
Contributor
There was a problem hiding this comment.
Not merging yet per last comments
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.
Description
BulkManagement::scheduleBulk()wraps its DB and publishing work in a try/catch that logs the exception message and returnsfalse— discarding the exception object entirely.MassSchedule::publishMass()checks the return value, getsfalse, and throws:No
$previousis attached. The root cause is gone. An operator or integrator receiving this error has nothing to work with — not the exception type, not the message, not the stack trace of the actual failure.Reproduction
Force a failure inside the
tryblock inscheduleBulk()and call the async bulk REST endpoint:Before fix:
{"message": "Something went wrong while processing the request."}No trace back to
BulkManagement. Root cause (e.g. "RabbitMQ connection refused") is invisible.Fix — two files, one PR
BulkManagement: Store the last caught exception in$this->lastException. Expose it viagetLastException().MassSchedule: Retrieve the stored exception and pass it as$previoustoLocalizedException.The
method_exists()guard ensures no BC break if a third-party implementsBulkManagementInterfacewithoutgetLastException().Impact of the fix
The message to API consumers remains
"Something went wrong while processing the request."— no change there. The benefit is in the exception chain:getPrevious()will now surface the root cause$e->getPrevious()->getMessage()to get the actual errorTest results
Contribution checklist