8000 [Serializer] Cannot get base type on `int|string` compound type · Issue #56874 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Serializer] Cannot get base type on int|string compound type #56874

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

Closed
ruudk opened this issue May 22, 2024 · 2 comments
Closed

[Serializer] Cannot get base type on int|string compound type #56874

ruudk opened this issue May 22, 2024 · 2 comments

Comments

@ruudk
Copy link
Contributor
ruudk commented May 22, 2024

Symfony version(s) affected

7.1-RC1

Description

The Serializer component switched to the new TypeInfo component and now our serialization breaks:

Symfony\Component\TypeInfo\Exception\LogicException : Cannot get base type on "int|string" compound type.

How to reproduce

final readonly class AddToCart
{
    /**
     * @param array<string, string|int> $metadata
     */
    public function __construct(
        public string $cartId,
        public array $metadata,
    ) {}
}

Symfony\Component\TypeInfo\Exception\LogicException : Cannot get base type on "int|string" compound type.
/Volumes/CS/www/cosmos/vendor/symfony/type-info/Type/UnionType.php:48
/Volumes/CS/www/cosmos/vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php:705
/Volumes/CS/www/cosmos/vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php:830
/Volumes/CS/www/cosmos/vendor/symfony/serializer/Normalizer/AbstractNormalizer.php:371
/Volumes/CS/www/cosmos/vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php:239
/Volumes/CS/www/cosmos/vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php:335
/Volumes/CS/www/cosmos/vendor/symfony/serializer/Serializer.php:238
/Volumes/CS/www/cosmos/vendor/symfony/serializer/Serializer.php:143

Possible Solution

No response

Additional Context

No response

@ruudk ruudk added the Bug label May 22, 2024
@OskarStark OskarStark changed the title [Serializer] Cannot get base type on "int|string" compound type [Serializer] Cannot get base type on int|string compound type May 24, 2024
@HypeMC
Copy link
Contributor
HypeMC commented May 27, 2024

@ruudk Could you see if #57197 fixes your issue?

@ruudk
Copy link
Contributor Author
ruudk commented May 28, 2024

@HypeMC This solves my problem too! Great work 🎉

fabpot added a commit that referenced this issue May 31, 2024
… (HypeMC)

This PR was merged into the 7.1 branch.

Discussion
----------

[Serializer] Fix denormalizing a collection of union types

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #56874
| License       | MIT

Commits
-------

0691eb8 [Serializer] Fix denormalizing a collection of union types
@fabpot fabpot closed this as completed May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0