Problem/Motivation

\Drupal\Core\EventSubscriber\ExceptionJsonSubscriber takes the exception message and wraps the exception message into an array and encodes it. This means we're currently getting a weird double encoding when returning an array of constraint errors

      $messages = array_map(static function (ConstraintViolationInterface $violation) {
        return sprintf("%s: %s", $violation->getPropertyPath(), $violation->getMessage());
      }, \iterator_to_array($constraints));
      throw new UnprocessableEntityHttpException(Json::encode([
        'errors' => $messages,
      ]));

There isn't a good way to return an array of errors. We'd have to borrow something like \Drupal\jsonapi\EventSubscriber\DefaultExceptionSubscriber but for the regular JSON format.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork simplytest-3190445

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mglaman created an issue. See original summary.

mglaman’s picture

Status: Active » Needs review

nerdstein made their first commit to this issue’s fork.

  • nerdstein committed e2eb084 on 8.x-4.x authored by mglaman
    Issue #3190445 by mglaman: Validation exceptions on launcher HTTP...
nerdstein’s picture

Status: Needs review » Fixed

Looks great thank you

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.