Problem/Motivation

When i do a GET with JSON:API the web server returns a 503 Bad Gateway, instantly. No errors in web, php logs or Drupal logs.

Only in database log i see this error:
"Got an error reading communication packets"

Steps to reproduce

This only happens in a very especial configuration.

I have 3 custom entities:
grandfather <--> father <--> son

Each one referencing the other with an entity reference.

When i do a GET of grandfather it's all ok. The same with grandfather and a includes of field_father (a field in grandfather referencing n fathers).

But if i do a GET with field_father.field_son (field_son is a field in father referencing n son) then the error happens.

If i use the sparse fieldsets to include son fields except the field that is referencing the father it works well.

Real examples:
assessment = grandfather
building_block = father
question = son

Error:
/jsonapi/sst_assessment/sst_assessment/afe6bc64-939a-433b-b593-656a7b1dcb06?include=field_building_blocks_results.field_question_results,field_assessment_template

No error:
/jsonapi/sst_assessment/sst_assessment/afe6bc64-939a-433b-b593-656a7b1dcb06?include=field_building_blocks_results.field_question_results,field_assessment_template&fields[sst_question_result--question_result_si_no]=field_impedimento,field_valor_respuesta,field_question

Comments

Carlitus created an issue. See original summary.

cilefen’s picture

Have you researched "mysql got an error reading communication packets"?

longwave’s picture

Sometimes this means that max_allowed_packet in your MySQL configuration is too small, you can try increasing this value.

carlitus’s picture

Thanks for the reply @cilefen and @longwave :)

And yes, I have looked at the two things you comment on and it seems that the error is not there.

longwave’s picture

The title says circular reference, is there actually a circular reference here (so grandfather -> father -> son -> grandfather or similar)?

As custom code is involved it is difficult to help without access to that code, perhaps you can reproduce this by adding similar entity references to nodes?

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.1.10 (June 4, 2021) and Drupal 9.2.10 (November 24, 2021) were the last bugfix releases of those minor version series. Drupal 9 bug reports should be targeted for the 9.3.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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.