Skip to content

fix(state): use exception message for user-facing violation when available#7894

Open
vincentchalamon wants to merge 5 commits into4.3from
fix/symfony-8.1-backend-enum-denormalizer
Open

fix(state): use exception message for user-facing violation when available#7894
vincentchalamon wants to merge 5 commits into4.3from
fix/symfony-8.1-backend-enum-denormalizer

Conversation

@vincentchalamon
Copy link
Copy Markdown
Contributor

When a NotNormalizableValueException has canUseMessageForUser() = true, use its message directly as the constraint violation message instead of the generic Type constraint message. This fixes issues with Symfony 8.x where expectedTypes can be null/empty, producing broken messages.

Q A
Branch? 4.3
Tickets Closes #7893
License MIT
Doc PR N/A

…lable

When a NotNormalizableValueException has canUseMessageForUser() = true,
use its message directly as the constraint violation message instead of
the generic Type constraint message. This fixes issues with Symfony 8.x
where expectedTypes can be null/empty, producing broken messages.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vincentchalamon vincentchalamon self-assigned this Mar 29, 2026
@vincentchalamon vincentchalamon changed the title fix(state): use exception message for user-facing violation when avai… fix(state): use exception message for user-facing violation when available Mar 29, 2026
vincentchalamon and others added 4 commits March 29, 2026 21:25
…expectedTypes

Simulates the behavior from symfony/serializer PR #62574 where an
invalid enum value produces an exception with expectedTypes=null and
a user-friendly message listing valid values.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ymfony compat

- Sort ValidationException import alphabetically in DeserializeProviderTest
- Update ValidationTest to expect exception message when canUseMessageForUser() is true
- Use positional params for NotNormalizableValueException ctor (lowest Symfony compat)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… violations

These violations have canUseMessageForUser()=true, so the new behavior
uses the exception message directly instead of the generic type message.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The extended NotNormalizableValueException constructor (with path and
useMessageForUser params) doesn't exist on lowest Symfony versions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant