fix: do not rethrow client-safe exceptions as internal (#1194) - #1249
Open
ousamabenyounes wants to merge 1 commit into
Open
fix: do not rethrow client-safe exceptions as internal (#1194)#1249ousamabenyounes wants to merge 1 commit into
ousamabenyounes wants to merge 1 commit into
Conversation
With rethrow_internal_exceptions enabled, ErrorHandler::treatExceptions() rethrew any exception that was not a UserError or UserWarning. A client-safe exception such as ArgumentsValidationException (implements ClientAware with isClientSafe() === true) is not internal, yet it bubbled up raw instead of being formatted into the response. Format client-safe ClientAware exceptions like a user error instead of rethrowing them; only genuinely internal (non-client-safe) exceptions are still rethrown. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ousamabenyounes
force-pushed
the
fix/issue-1194
branch
from
August 10, 2026 14:38
81d5f63 to
1a5d47a
Compare
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.
Problem
With
errors_handler.rethrow_internal_exceptionsenabled,ErrorHandler::treatExceptions()rethrows every exception that is not a
UserErroror aUserWarning:The option is documented as "re-throw internal exception", but a client-safe exception
such as
ArgumentsValidationException(implementsGraphQL\Error\ClientAwareand returnstruefromisClientSafe()) is not internal. It was nonetheless rethrown and bubbledup raw instead of being formatted into the GraphQL response.
Fix
Before the rethrow, format any client-safe
ClientAwareexception like a user error.Only genuinely internal (non-client-safe) exceptions are still rethrown. The default
path (
rethrow_internal_exceptions = false) is unchanged: such exceptions already endedup in the formatted errors.
Test verification (RED → GREEN)
New test wraps an
ArgumentsValidationExceptionand callshandleErrors($result, true).RED — on the unmodified branch (fix reverted, test only), the exception is rethrown:
GREEN — with the fix, it is formatted into the response:
Full suite is iso-baseline (the 5 pre-existing
GraphDumpSchemaCommandTestfailures onmasterare unrelated and unchanged):Tests: 713, Failures: 5.