Skip to content

fix(serializer): Catch MissingConstructorArgumentsException - #8659

Merged
soyuka merged 1 commit into
api-platform:5.0from
bram123:catch_missing_constructor_param_exception
Oct 9, 2026
Merged

soyuka merged 1 commit into
api-platform:5.0from
bram123:catch_missing_constructor_param_exception

Conversation

@bram123

@bram123 bram123 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor
Q A
Branch? 5.0 for bug fixes
Tickets
License MIT
Doc PR

When you have an input DTO with required constructor params, and a request comes in without those fields, API-Platform would leak information about the internal API codebase.
This is now caught and a generic "The input data is misformatted." is used instead.

Created new testCustomInputRejectsBadTypeMissingConstructorParam to assert the new behaviour.

Before:
Cannot create an instance of "ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\JsonLd\RequiredConstructorInputDto" from serialized data ...
After:
The input data is misformatted.

The existing NotNormalizableValueException catch (asserted by testCustomInputRejectsBadType) already turns
The type of the "bar" attribute must be "int|null", "string" given.
into
The input data is misformatted.

@bram123
bram123 force-pushed the catch_missing_constructor_param_exception branch from 619335f to e1cd400 Compare October 9, 2026 09:22
@bram123
bram123 force-pushed the catch_missing_constructor_param_exception branch from e1cd400 to d43e8b0 Compare October 9, 2026 09:24
@bram123

bram123 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

PHPStan warning should be unrelated to me adding an extra catch statement

@soyuka
soyuka merged commit ce64745 into api-platform:5.0 Oct 9, 2026
116 of 117 checks passed
@soyuka

soyuka commented Oct 9, 2026

Copy link
Copy Markdown
Member

thanks!

@bram123
bram123 deleted the catch_missing_constructor_param_exception branch October 9, 2026 15:00
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.

2 participants