Skip to content

[LiveComponent] Fix dehydrating arrays of entities with a Uuid identifier - #4169

Merged
Kocal merged 1 commit into
symfony:3.xfrom
HawkForge:fix/uuid-id-array-dehydrate
Nov 4, 2026
Merged

Kocal merged 1 commit into
symfony:3.xfrom
HawkForge:fix/uuid-id-array-dehydrate

Conversation

@HawkForge

Copy link
Copy Markdown
Contributor
Q A
Bug fix? yes
New feature? no
Deprecations? no
Documentation? no
Issues Fix #3410
License MIT

Thanks to @redclov3r for the report and the analysis.

DoctrineEntityHydrationExtension::dehydrate() returns the entity identifier as-is. For an entity whose id is a Symfony Uid (e.g. with UuidType) that is a Uuid object. For a #[LiveProp] array of entities, LiveComponentHydrator then runs isValueValidDehydratedValue() on the result, which only accepts scalars and arrays, and throws "Unable to dehydrate value of type array".

The extension now casts AbstractUid identifier values to strings (this also covers composite ids). Integer/string ids are unchanged, and the string is accepted by EntityManager::find() with UuidType, so hydration works unchanged.

Tests: a new Uuid-id entity fixture, an extension round-trip test, and a LiveComponentHydratorTest case with an array of such entities. Both fail without the fix (Uuid object returned / LogicException) and pass with it. No CHANGELOG entry, as recent bugfix PRs add none.


Replaces #4131, which got closed when my fork was accidentally detached.

@carsonbot carsonbot added Bug Bug Fix LiveComponent Status: Needs Review Needs to be reviewed labels Oct 29, 2026
@Kocal
Kocal force-pushed the fix/uuid-id-array-dehydrate branch from 5498fd8 to d8e5251 Compare November 4, 2026 07:46
@carsonbot carsonbot added Status: Reviewed Has been reviewed by a maintainer and removed Status: Needs Review Needs to be reviewed labels Nov 4, 2026
@Kocal

Kocal commented Nov 4, 2026

Copy link
Copy Markdown
Member

Thank you @HawkForge.

@Kocal
Kocal merged commit cf7e2e5 into symfony:3.x Nov 4, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Bug Fix LiveComponent Status: Reviewed Has been reviewed by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[LiveComponent] Hydration fails on arrays of entities whose identifier is an UUID (object)

3 participants