Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation errors are lost when exception is thrown #15

Open
mxr576 opened this issue Feb 23, 2023 · 0 comments · May be fixed by #16
Open

Validation errors are lost when exception is thrown #15

mxr576 opened this issue Feb 23, 2023 · 0 comments · May be fixed by #16

Comments

@mxr576
Copy link

mxr576 commented Feb 23, 2023

justinrainbow/json-schema's Validator object is stateless, so even is $this->doUndoTransform($data, $context) performs a validation and concludes that the output failed on the schema validation in the parent scope, the $validator = $this->getOutputValidator(); $validator->getErrors(); call is going to return an empty array because validation errors are only available on the object after $validator->isValid() is called.

https://github.com/e0ipso/shaper/blob/master/src/DataAdaptor/DataAdaptorTransformerTrait.php#L57-L66

I have spotted this when I analyzed Drupal log and I saw this

TypeError: Adaptor Drupal\jsonapi_extras\Plugin\ResourceFieldEnhancerBase returned invalid output data: [] in Drupal\jsonapi_extras\Plugin\ResourceFieldEnhancerBase->undoTransform() (line 66 of /mnt/files/local_mount/build/vendor/e0ipso/shaper/src/DataAdaptor/DataAdaptorTransformerTrait.php)

instead of this

TypeError: Adaptor Drupal\jsonapi_extras\Plugin\ResourceFieldEnhancerBase returned invalid output data: [{"property":"format","pointer":"/format","message":"NULL value found, but a string is required","constraint":"type","context":1}] in Drupal\jsonapi_extras\Plugin\ResourceFieldEnhancerBase->undoTransform() (line 66 of /mnt/files/local_mount/build/vendor/e0ipso/shaper/src/DataAdaptor/DataAdaptorTransformerTrait.php)

@mxr576 mxr576 linked a pull request Feb 28, 2023 that will close this issue
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 a pull request may close this issue.

1 participant