- Issue created by @wolffereast
- πΊπΈUnited States wolffereast
Adding an interim patch which fixes the form for now
- Merge request !53Resolve #3545168 "Accounts with no Apps break migrations" β (Open) created by drunken monkey
Attempting to use the Migrate operation to migrate a search server using a searchstax user with multiple Accounts will throw an error if any of the Accounts does not have an App.
In MigrateServerForm.php on line 201 the form attempts to retrieve all Apps for a specified account name in order to build an options array. That calls getApps on line 206 of Api.php, which in turn calls sendApiRequest
$data = $this->sendApiRequest('GET', '/apps', ['account' => $account]);
Accounts with no Apps return an empty body as no Apps are available which triggers the conditional on line 580
if ($response->getStatusCode() !== 200 || !$data) {
That results in the following error message and a broken form:
Drupal\searchstax\Exception\SearchStaxException: HTTP 200 response from server: [] in Drupal\searchstax\Service\Api->sendApiRequest() (line 591 of /var/www/html/docroot/modules/contrib/searchstax/src/Service/Api.php).
It seems that the empty body in the return is a valid response and shouldn't be treated as an error. I don't know where else the method is used so I don't want to change the return if there are assumptions that an empty response throws an error elsewhere. A possible first step would be to catch the exception and message an error but allow the form to continue building to see if other Accounts have Apps. something like the following
try {
foreach ($this->searchStaxApi->getApps($account_name) as $app_id => $app) {
...
}
}
catch (SearchStaxException $e) {
if ($e->getCode() === 200 && !$e->getResponse()) {
$this->messenger()->addError($this->t('%account_name has no Apps to select', ['%account_name' => $account_name]));
}
else {
throw SearchStaxException::fromPrevious($e);
}
}
That allows the form to be used and alerts the user to the Account that needs an App before it can be used.
Active
1.7
Solr Migration sub-module
Adding an interim patch which fixes the form for now