Problem/Motivation

See https://git.drupalcode.org/issue/jsonapi_extras-3563549/-/jobs/11983364 for a failing run.

The problem is

1) Drupal\Tests\jsonapi_extras\Kernel\EntityToJsonApiTest::testSerialize
PHPUnit\Framework\Exception: Uncaught PHP Exception TypeError: "str_contains(): Argument #1 ($haystack) must be of type string, null given" at /builds/issue/jsonapi_extras-3563549/web/core/modules/jsonapi/tests/modules/jsonapi_response_validator/src/EventSubscriber/ResourceResponseValidator.php line 69
2) Drupal\Tests\jsonapi_extras\Kernel\EntityToJsonApiTest::testRequestStack
PHPUnit\Framework\Exception: Uncaught PHP Exception TypeError: "str_contains(): Argument #1 ($haystack) must be of type string, null given" at /builds/issue/jsonapi_extras-3563549/web/core/modules/jsonapi/tests/modules/jsonapi_response_validator/src/EventSubscriber/ResourceResponseValidator.php line 69
ERRORS!

which is a problem in core.

See https://www.drupal.org/project/drupal/issues/3344629

Steps to reproduce

Proposed resolution

Can be closed without an MR if fixed upstream.

Remaining tasks

User interface changes

API changes

Data model changes

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

penyaskito created an issue.

f0ns’s picture

As described above the root cause is in core, not here. HeaderBag::get() returns NULL for a header present with a NULL value, so the '' default in ResourceResponseValidator does not prevent the TypeError.

Core MR: merge request 17048 (#3344629: Passing null to parameter #1 ($haystack) of type string is deprecated)

Note on scope: I could not reproduce this on 8.x-3.x HEAD. Both EntityToJsonApiTest tests pass there on core 11.4.5. It reproduces on the MR branch for #3563549: Missing config schema for field enhancers, which is what pipeline 11983364 ran.

With the core fix applied, both tests pass: 88 assertions, previously 0.

bbrala’s picture

I think the MR just needs a rebase. Seems to be fixed already in #3512041?

bbrala’s picture

Added a small test for regression possibilities on the EntityToJsonApi service.