Problem/motivation

This issue was openend way back and referenced in the json:api code. Since this issue is deemed outdated, the reference to the issue should be removed from core.

Remaining tasks

Remove reference to this issue from: core/modules/jsonapi/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php:217

Old IS

Issue title pretty much says it all, but there are certainly other clean-ups to be done in the exception classes, like these static \Drupal:: bits:

$error['links']['via']['href'] = \Drupal::request()->getUri();

and

$resource_type = \Drupal::service('jsonapi.resource_type.repository')->get($entity_type_id, $bundle);
$resource_type_name = $resource_type->getTypeName();
$route_name = !is_null($relationship_field)
  ? "jsonapi.$resource_type_name.$relationship_field.related"
  : "jsonapi.$resource_type_name.individual";
$url = Url::fromRoute($route_name, ['entity' => $entity->uuid()]);
$errors[0]['links']['via']['href'] = $url->setAbsolute()->toString(TRUE)->getGeneratedUrl();

Issue fork drupal-3036284

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:

Comments

gabesullice created an issue. See original summary.

gabesullice’s picture

Title: Clean-up: *Exception::buildErrors returns an array of errors, but never return >1 error. » Clean-up: *Exception::buildErrors returns an array of errors, but never returns >1 error.
gabesullice’s picture

Title: Clean-up: *Exception::buildErrors returns an array of errors, but never returns >1 error. » [PP-1] Clean-up: *Exception::buildErrors returns an array of errors, but never returns >1 error.
Related issues: +#3036286: Clean-up: JsonApiDocumentTopLevelNormalizer and children to prep for further clean-ups
gabesullice’s picture

Status: Active » Postponed
gabesullice’s picture

Title: [PP-1] Clean-up: *Exception::buildErrors returns an array of errors, but never returns >1 error. » Clean-up: *Exception::buildErrors returns an array of errors, but never returns >1 error.
wim leers’s picture

Priority: Normal » Minor
Status: Postponed » Active
wim leers’s picture

Project: JSON:API » Drupal core
Version: 8.x-2.x-dev » 8.8.x-dev
Component: Code » jsonapi.module
wim leers’s picture

Assigned: Unassigned » gabesullice

I started implementing this, but then I noticed that \Drupal\jsonapi\Normalizer\UnprocessableHttpEntityExceptionNormalizer::buildErrorObject() in fact does generate multiple error objects :)

(Yes, this has since been renamed from ::buildErrors() to ::buildErrorObjects().)

If you can confirm this, let's close this!

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

gabesullice’s picture

Assigned: gabesullice » Unassigned
Status: Active » Closed (outdated)

Sorry for taking so long to confirm this. I didn't want to close this issue because I remember that when I created it I was really irked by some non-obvious wonkiness. Honestly, I don't remember the specifics even though I'm positive that we haven't done anything that would have addressed it—I should have been much more verbose in the issue summary.

Long story short, I'm closing this as outdated because the issue title is about *Exception::buildErrors, which doesn't even exist anymore (it was refactored into HttpExceptionNormalizer::buildErrorObjects()).

I think the gremlins are still hiding somewhere around here, but we'll just have to open a new issue when they come out to play.

bbrala’s picture

Version: 8.9.x-dev » 11.x-dev
Issue summary: View changes
Status: Closed (outdated) » Active
Issue tags: +Novice

This issue is referenced in the code of json:api core/modules/jsonapi/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php:217. If we decided this is not an issue we should use this issue to remove the reference.

Soham Sengupta made their first commit to this issue’s fork.

soham sengupta’s picture

Status: Active » Needs review

I have removed the reference from the code and created the MR. Moving the issue to Needs Review state.
Thank you.

arun.k’s picture

@Soham Sengupta i have checked the merge request MR !8532 and found the refrence from the file core/modules/jsonapi/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php has been removed and working fine.
Step to check
1. install drupal 11.x on DDEV v1.22.6 and php 8.3.0
2. use command git remote add drupal-3036284 https://git.drupalcode.org/issue/drupal-3036284.git
3. git fetch drupal-3036284
4. git checkout -b '3036284-clean-up-exceptionbuilderrors-returns' --track drupal-3036284/'3036284-clean-up-exceptionbuilderrors-returns'
and found removed refrence from the code

arun.k’s picture

Status: Needs review » Reviewed & tested by the community
bbrala’s picture

All good, thank you.

quietone’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -Novice

Not sure about this. The coding standards state

Usually, a corresponding Drupal.org issue should be created for the @todo and referenced in it.

That recommends that this @todo should link to the issue where the work is being done. That helps us find the work to do, a @todo without an issue tends to be forgotten. I'd much rather this have a link to an issue.

bbrala’s picture

You are right, not sure how i missed that.

The change did not so as per IS, remove the whole todo.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.