Skip to content

Validator throws Uncaught PHP Exception #5916

@divine

Description

@divine

API Platform version(s) affected: 3.2.1

Custom validation throws an Uncaught PHP Exception

[2023-10-21T10:21:01.781619+00:00] request.CRITICAL: Uncaught PHP Exception ApiPlatform\Symfony\Validator\Exception\ValidationException: "field: The field is not valid." at /apiplatform/vendor/api-platform/core/src/Symfony/Validator/Validator.php line 60

Description

How to reproduce

Create a custom validation and then check the error log.

Possible Solution

Custom validation error shouldn't throw Uncaught PHP Exception

Additional Context

Probably code is empty and it's the reason why it's throwing error:

{
	"status": 422,
	"violations": [
		{
			"propertyPath": "field",
			"message": "The data \"test\" is not valid.",
			"code": null
		}
	],
	"detail": "field: The data \"test\" is not valid.",
	"type": "\/validation_errors\/00000000000004b00000000000000000",
	"title": "An error occurred"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions