Problem/Motivation
After setting up an external entity, In the REST storage client, if you have your Page parameter and Page size parameter values setup correctly. Then you must also have a value for Default number of items per page for your entitylist page to work.
If you don't put in a value, you get the following error when going to your entitylist page:
The website encountered an unexpected error. Try again later.
TypeError: Unsupported operand types: int / string in Drupal\external_entities\Plugin\ExternalEntities\StorageClient\Rest->getPagingQueryParameters() (line 457 of modules/contrib/external_entities/src/Plugin/ExternalEntities/StorageClient/Rest.php).
If you put in a value of zero,in other drupal paradigms putting in zero would allow you to fetch all items, you get the following error when going to your entitylist page:
The website encountered an unexpected error. Try again later.
DivisionByZeroError: Division by zero in Drupal\external_entities\Plugin\ExternalEntities\StorageClient\Rest->getPagingQueryParameters() (line 457 of modules/contrib/external_entities/src/Plugin/ExternalEntities/StorageClient/Rest.php).
Relevant issue about the unclear behavior of the Default number of items per page β
, which in my experience actually acts as a cap on the number of items fetched from the source. It also needs to match an allowed page size value from the source, like you must do if setting it up using a drupal rest export, for example. Neither of those things are clear, when setting up an external entity, nor in any documentation I could find.
Lastly, and slightly unrelated to this exact topic, if you setup a REST export from a drupal sources site, which is what I was testing on, you must fill in the Page parameter and Page size parameter to get the tracking of your external entity setup correctly in search api. This also wasn't clear anywhere when setting up an external entity, if this is even a known constraint. I mention this here, because at minimum the description of the fields should be updated to reflect their importance, including the default number of items per page. Also this issue described above only arises when both Page parameter and Page size parameter values are supplied. Because that is the only condition that makese the default number of items per page relevant.
Steps to reproduce
- install external entities
- setup an external entity to track a REST endpoint in json format with page and page size parameters setup and working, I was using a drupal source.
- add a Default number of items per page value
- save entity
- confirm your external entity data is being pulled in correctly at your entitylist page
- confirm errors:
- edit your external entity, put 0 into the Default number of items per page, save and go to your entity list page you should see the error listed above
- go back and edit your external entity, put no value into the Default number of items per page, save and go to your entity list page you should see the other error listed above
Proposed resolution
- At a minimum: Add better field descriptions to inform users of what these fields actually do and what values need to go into them.
- Setup field validation to require a value for the Default number of items per page, and to make sure it is not zero.
- Add protective code in getPagingQueryParameters to ensure these errors don't arise, even with field validation.
Remaining tasks
User interface changes
API changes
Data model changes