API Platform version(s) affected: 4.2.1
Description
When setting enable_attributes: false in the Symfony framework serializer configuration, the API error response content becomes empty.
This seems to indicate that the enable_attributes flag also affects the internal error decoding process, which likely isn’t the intended behavior.
How to reproduce
Use the official api-platform/demo project.
In config/packages/framework.yaml, add the following under the serializer section:
serializer:
enable_attributes: false
Trigger a validation error (e.g., by submitting invalid data).
Observe that the response body is empty instead of returning a proper error structure.
Possible Solution
Review how the error normalization/serialization is handled in:
api-platform/core/src/State/ApiResource/Error.php
api-platform/core/src/Validator/Exception/ValidationException.php
ErrorResource attributes could be implemented into a separate config or could be improved the documentation on serialization.
Alternatively, clarify this behavior in the documentation if it is intended.
Additional Context
This issue might lead to confusion when integrating API Platform with projects that disable attribute-based metadata for specific reasons (e.g., performance or consistency).
Providing either a dedicated configuration for ErrorResource serialization or clearer documentation would help improve developer experience.
API Platform version(s) affected: 4.2.1
Description
When setting enable_attributes: false in the Symfony framework serializer configuration, the API error response content becomes empty.
This seems to indicate that the enable_attributes flag also affects the internal error decoding process, which likely isn’t the intended behavior.
How to reproduce
Use the official api-platform/demo project.
In config/packages/framework.yaml, add the following under the serializer section:
serializer:
enable_attributes: false
Trigger a validation error (e.g., by submitting invalid data).
Observe that the response body is empty instead of returning a proper error structure.
Possible Solution
Review how the error normalization/serialization is handled in:
api-platform/core/src/State/ApiResource/Error.php
api-platform/core/src/Validator/Exception/ValidationException.php
ErrorResource attributes could be implemented into a separate config or could be improved the documentation on serialization.
Alternatively, clarify this behavior in the documentation if it is intended.
Additional Context
This issue might lead to confusion when integrating API Platform with projects that disable attribute-based metadata for specific reasons (e.g., performance or consistency).
Providing either a dedicated configuration for ErrorResource serialization or clearer documentation would help improve developer experience.