Closed (fixed)
Project:
JSON:API
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
19 Jul 2018 at 15:11 UTC
Updated:
10 Oct 2018 at 10:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
e0ipsoComment #4
e0ipsoComment #6
wim leersThis is related to #2986484: Add verbose logging to failed assertions for base path and https://github.com/contentacms/contenta_jsonapi/issues/301, which triggered both of these.
This was done to unblock https://github.com/contentacms/contentajs — see http://humanbits.es/web-development/2018/07/16/contentajs/.
Then rather than removing them, let's assert them only if the container is fully ready if at all possible.
Before #2986484, the error looked like this:
What did it look like afterwards? That would tell us what value the
assert()was receiving. We need that information to determine whether we want this to have a follow-up, and if so, what that follow-up should do.I'm happy to do all that, but I can't without the necessary information :) Hence marked . Could you post that error output? Thanks!
Comment #7
e0ipsoI could see it being set to
/which was very puzzling.Comment #8
wim leersThanks for posting that info — I'll follow up on this on Sunday or Monday :) Marking to reflect that I'm about to dig into it to understand how it could be set to that value.
Comment #9
wim leersI bet that was because
\Drupal\jsonapi_extras\JsonapiExtrasServiceProvider::alter()does:It's conceivable that very early during the installation process,
$settingsis still empty.In fact, I can reproduce this even outside the installation process of a distro: with just vanilla Drupal core +

jsonapi, then installingjsonapi_extrasresults in this:This is therefore a bug in
jsonapi_extras, notjsonapi. It was introduced in #2982133: No longer works with JSON API >=1.21 (so either 1.21 or 1.22), which was done in response to #2971745: Don't hardcode `/jsonapi/` in FormatSetter, read JSON API base path from container parameter instead.Comment #11
wim leersD'oh.
Comment #12
wim leersForgot the screenshot for #9.
Comment #13
wim leersSo, ideally:
Comment #14
e0ipsoIf we did that, will we be back to an assertion error? Then
$jsonapi_base_pathwould be set toNULLand we'd haveassert(is_string($jsonapi_base_path));back in place.Comment #15
wim leers(Sorry for the late reply, I was on vacation since July 24 until this past weekend!)
Why would
$jsonapi_base_pathbe set toNULL?jsonapi.services.ymlsets it to"/jsonapi". That's guaranteed to be the value, unless aServiceModifierInterfaceimplementation alters it. And that's whatjsonapi_extraswas doing! And the only reason it even ever caused a problem, is because it overrides that container parameter based on configuration, which indeed is kind of tricky to access during installation. Hence the patch in #9 fixes this.(I tested the patch in #9 with
jsonapi_extras— before that patch core +jsonapi+jsonapi_extraswould indeed cause the problem you originally reported; with that patch it's fixed! 🙂)Comment #16
wim leersPer #9, created #2991767: jsonapi.base_path container parameter should only be overridden if JSON API Extras' configuration is available to fix the bug in JSON API Extras.
The next step here is to revert this patch. I'm fine with leaving this patch committed to 1.x even though it never should've been committed, nor should https://www.drupal.org/project/jsonapi/releases/8.x-1.23 have been released.
But in the 2.x branch, I want these assertions restored, to prevent future confusion and painful debugging. That's the reason those assertions exist!
So,:
Comment #17
gabesulliceConfirmed that the code path in JSON API Extras was fixed to resolve this issue.
LGTM
Comment #18
wim leersThanks to @e0ipso for committing #2991767: jsonapi.base_path container parameter should only be overridden if JSON API Extras' configuration is available!
The patch needs a reroll by now. #2987205: FormatSetter doesn't set the format to `api_json` when accessing just `/jsonapi` removed the
FormatSetterclass. Fortunately, that means we can just move the more verbose (and more helpful!) assertions fromFormatSettertoRoutes. IOW: the patch just becomes smaller and achieves the same.Comment #20
wim leers4 failures due to something that is freshly deprecated in 8.6 and 8.7 as of today: #2998888: Drupal\field\Tests\EntityReference\EntityReferenceTestTrait deprecated. Asked for advice how to deal with it in #2996789: Deprecate Drupal\field\Tests\EntityReference\EntityReferenceTestTrait.
Tests are actually passing. Failures are just for deprecation notices.
Comment #21
wim leersComment #22
wim leersWorking to get those 4 failures due to #2996789: Deprecate Drupal\field\Tests\EntityReference\EntityReferenceTestTrait resolved in #3001958: 4 test fails due to using deprecated code on 8.6 and 8.7 since #2996789: temporarily fork the test trait.
Comment #23
wim leers#3001958: 4 test fails due to using deprecated code on 8.6 and 8.7 since #2996789: temporarily fork the test trait landed, retesting.
Comment #25
wim leers🎉