- Merge request !3184Issue #3330474: JSON:API should include validation constraint violations in log context β (Open) created by bradjones1
- πΊπΈUnited States bogdog400
Let me just add that at this moment, some details about what's missing or malformed in a JSON packet would be very, very helpful. I'm pulling my hair out over some 422 errors that weren't there before I added a field.
I will dig in a bit myself but I want to encourage others to post any quick solutions like a patch.
- πΊπΈUnited States bradjones1 Digital Nomad Life
I will dig in a bit myself but I want to encourage others to post any quick solutions like a patch.
There is an open MR.
- πΊπΈUnited States bogdog400
I tried the patch but couldn't get it to work. Alas.
Also, this is logging code wouldn't work for me either when I inserted it in core/modules/jsonapi/src/Exception/UnprocessableHttpEntityException.php
\Drupal::logger('myerror')->warning('This is my error:'. print_r($violations) );
But this did:
\Drupal::logger('myerrror')->warning('This is my error:'. $this->$violations->getFieldNames() );
It didn't generate the kind of log that I wanted, though. But the log message said that "getFieldNames" didn't exist and then it included a nice print out of the rest of the object which helped me solve the problem.
I'm fully aware that i wasn't doing the right thing with the PHP, but it was rather maddening and I'm leaving this as a potential help for others who experience it.
I'm happy to test another patch if someone creates it. Thx.
- πΊπΈUnited States bogdog400
Here's a better version for logging. (Is there some good way to serialize PHP arrays? There must be a function.) There's usually just one violation. If there are more, you can add print options for them too.
/** * Sets the constraint violations associated with this exception. * * @param \Drupal\Core\Entity\EntityConstraintViolationListInterface $violations * The constraint violations. */ public function setViolations(EntityConstraintViolationListInterface $violations) { $this->violations = $violations; $this->message = "Unprocesseable Entity: Violations:".$violations[0]; }
- Status changed to Needs review
8 months ago 6:51am 20 May 2024 - πΊπΈUnited States bradjones1 Digital Nomad Life
Back to NR for feedback per #9.
- Status changed to Needs work
8 months ago 7:27am 20 May 2024 The Needs Review Queue Bot β tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide β to find step-by-step guides for working with issues.
- Status changed to Needs review
8 months ago 2:01am 21 May 2024 - πΊπΈUnited States bradjones1 Digital Nomad Life
Back to NR. Tests updated as well.
- π³π±Netherlands bbrala Netherlands
I don't see tests? Am i missing something?
- Status changed to Active
8 months ago 4:03pm 24 May 2024 - πΊπΈUnited States bradjones1 Digital Nomad Life