Add Logging to JsonApi pre Patch Exception

Created on 8 December 2022, about 2 years ago
Updated 19 February 2023, almost 2 years ago

Problem/Motivation

Provide Developers better log messages of violations pre Exception is thrown when patching an entity.

Steps to reproduce

this is across the board Example:

Allow User Entity to be Patched - this means you need to GET the current Entity first to get the Expected values
then change or add any value say in postman
then Make A patch Call - this is fine

however if you then go make a new required field on that entity or have another person at your work place add a few fields

Then make the same PATCH call as before = Exceptions being thrown

Such as:

Drupal\jsonapi\Exception\UnprocessableHttpEntityException: Unprocessable Entity: validation failed. in Drupal\jsonapi\Controller\EntityResource::validate() (line 59 of /app/web/core/modules/jsonapi/src/Entity/EntityValidationTrait.php).

or

Drupal\jsonapi\Exception\UnprocessableHttpEntityException: Unprocessable Entity: validation failed. in Drupal\jsonapi\Controller\EntityResource::validate() (line 59 of /app/web/core/modules/jsonapi/src/Entity/EntityValidationTrait.php).

These are fine but don't really provide info on what to do to fix the issue

Proposed resolution

Simply add a log message of the violation so a developer can easily see the issue

Example: ( from patched version)

Object(Drupal\Core\Entity\Plugin\DataType\EntityAdapter).field_phone: is empty

As you can see it gives a quicker way to debug whatever complex api driven thing your doing

Feature request
Status

Needs work

Version

10.1

Component
JSON API 

Last updated 9 days ago

Created by

🇦🇺Australia taggartj

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

    Seems like this could use simple test coverage. Nothing crazy just to show this does log correctly.

Production build 0.71.5 2024