Skip to content

Don't lose the original exception when the fallback AdminContext creation fails#7715

Merged
javiereguiluz merged 1 commit into
EasyCorp:5.xfrom
guillaume-sainthillier:preserve-original-exception-in-admin-router-subscriber
Jul 22, 2026
Merged

Don't lose the original exception when the fallback AdminContext creation fails#7715
javiereguiluz merged 1 commit into
EasyCorp:5.xfrom
guillaume-sainthillier:preserve-original-exception-in-admin-router-subscriber

Conversation

@guillaume-sainthillier

Copy link
Copy Markdown
Contributor

When context creation fails (e.g. entity not found), the subscriber
builds a fallback context without the entity to render the error page
with the EasyAdmin layout. That second AdminContextFactory::create()
call runs user-defined code (configureActions(), action extensions)
against a context whose entity is null, so it can throw as well.

Without a guard, that secondary error replaced the original exception
and the stripped entityId/id/_route_params attributes were never
restored. The fallback creation is now wrapped in try/finally: the
original exception is always rethrown and the attributes are always
restored.

…tion fails

When context creation fails (e.g. entity not found), the subscriber
builds a fallback context without the entity to render the error page
with the EasyAdmin layout. That second AdminContextFactory::create()
call runs user-defined code (configureActions(), action extensions)
against a context whose entity is null, so it can throw as well.

Without a guard, that secondary error replaced the original exception
and the stripped entityId/id/_route_params attributes were never
restored. The fallback creation is now wrapped in try/finally: the
original exception is always rethrown and the attributes are always
restored.
@guillaume-sainthillier
guillaume-sainthillier force-pushed the preserve-original-exception-in-admin-router-subscriber branch from 805b27e to e6287aa Compare July 13, 2026 07:33
@javiereguiluz javiereguiluz added this to the 5.x milestone Jul 22, 2026
@javiereguiluz

Copy link
Copy Markdown
Collaborator

Thank you Guillaume.

@javiereguiluz
javiereguiluz merged commit dd250a5 into EasyCorp:5.x Jul 22, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants