[13.x] Keep the assertion failure message when session errors are JSON serialized - #61201
Open
lazerg wants to merge 1 commit into
Open
[13.x] Keep the assertion failure message when session errors are JSON serialized#61201lazerg wants to merge 1 commit into
lazerg wants to merge 1 commit into
Conversation
lazerg
force-pushed
the
fix/test-response-assert-json-session-errors
branch
from
August 15, 2026 08:40
ec69874 to
25a26c8
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.
Store::save()replaces the in-memoryViewErrorBagwith a plain array when the session serializes to JSON, and never puts the object back.TestResponse::session()hides this because it restarts the session, which runsmarshalErrorBag()and rebuilds the bag, butTestResponseAssert::injectResponseContext()reads the redirect response's session directly and calls->all()on whatever is there.So on a failing assertion against a redirect carrying validation errors, the helper throws
Error: Call to a member function all() on arrayand that replaces theExpectationFailedExceptionit was meant to enrich. The real failure message, the expected and actual values and the validation messages are all gone, and the trail points at a framework internal rather than the test. It only shows up once an assertion is already failing, so a green suite never surfaces it, andjsonis the shipped default for new applications.Starting the session before reading the errors lets the store marshal the bag back, so the assertion message keeps both the original failure and the validation errors.
Fixes #61200