Skip to content

Disabling symfony attributes have an impact on error decoding #8174

@andrecela01

Description

@andrecela01

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions