Skip to content

issue 1022. fix missing _route on live components batch requests #2767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from

Conversation

arrabiata-asanz
Copy link

@arrabiata-asanz arrabiata-asanz commented May 23, 2025

Q A
Bug fix? yes
New feature? no
Docs? no
Issues Fix #1022
License MIT

The _route param get overwritten for Live Component Batch Requests, persist this param to the sub requests

Symfony\UX\LiveComponent\Controller\BatchActionController

$request->duplicate(attributes: [
                '_controller' => [$serviceId, $name],
                '_component_action_args' => $action['args'] ?? [],
                '_mounted_component' => $_mounted_component,
                '_live_component' => $serviceId,
            ]

$response = $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST, false);

Duplicate overwrites all attributes in the sub request, missing one important attribute _route, add it to the array in order to know where the request comes from.

@carsonbot carsonbot added Bug Bug Fix Status: Needs Review Needs to be reviewed labels May 23, 2025
@arrabiata-asanz
Copy link
Author

i think the failed tests don't apply to the changes in this PR. (Deprecation warning and Exception Messages Formatting)

@Kocal
Copy link
Member

Kocal commented May 23, 2025

Thanks for the PR! I'm totally not familiar with LiveComponent, but:

  1. can we add a test preventing any regression?
  2. I think we should also pass _route_params, no?

@Kocal
Copy link
Member

Kocal commented May 23, 2025

i think the failed tests don't apply to the changes in this PR. (Deprecation warning and Exception Messages Formatting)

Yes you can ignore the 8.4 dev job, but for fabbot, it would be nice to fix it (even if not related :) )

@smnandre
Copy link
Member

Hmm.. could we also add some tests for this?

@smnandre smnandre requested a review from Copilot May 25, 2025 01:17
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the issue where the _route attribute was omitted in live component batch requests, ensuring that it is preserved during sub-request duplication.

  • Added the missing '_route' attribute in the request duplication for batch processing.
Comments suppressed due to low confidence (1)

src/LiveComponent/src/Controller/BatchActionController.php:41

  • Consider verifying that '_route' is not null or documenting the behavior when it is absent to avoid potential issues in downstream sub-request handling.
'_route' => $request->attributes->get('_route'),

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.

BatchActionController isn't passing default route attributes
4 participants