pimcore/data-hub

[Improvement]: Fix inconsistency when creating/updating and running into a validation exception

Closed this issue · 2 comments

Improvement description

For a project we hooked in onto the DataObjectEvents::PRE_UPDATE event to validate some data and we throw a Pimcore\Model\Element\ValidationException when the validation fails. This logic is executed every time we save a product.

When we use Datahub (GraphQL) to create/update objects, and validation fails, we get inconsistent responses. This is caused because we end up in different resolve functions.

In MutationType.php#L839 you'll see that when saving fails it's being caught and you return an array with success and message.
However around line 660 an eventual Exception is not caught. So you'll end up with a generic non-informative message (and stack trace in debug mode).

I think this could be easily fixed by adding a try/catch around line 660 too.

Since it's almost no effort I've created a PR already: #866

Thanks a lot for reporting the issue. We did not consider the issue as "Pimcore:Priority", "Pimcore:ToDo" or "Pimcore:Backlog", so we're not going to work on that anytime soon. Please create a pull request to fix the issue if this is a bug report. We'll then review it as quickly as possible. If you're interested in contributing a feature, please contact us first here before creating a pull request. We'll then decide whether we'd accept it or not. Thanks for your understanding.