Accounts with no Apps break migrations

Created on 5 September 2025, about 2 months ago

Problem/Motivation

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).

Steps to reproduce

  • Install the searchstax and solr_to_searchstax_ss_migration modules on a site with an existing solr server.
  • Click Migrate under Operations next to the server
  • Provide searchstax credentials for a user that has access to an Account with no App
  • The logged in message should show in green, then the error in red

Proposed resolution

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.

πŸ› Bug report
Status

Active

Version

1.7

Component

Solr Migration sub-module

Created by

πŸ‡ΊπŸ‡ΈUnited States wolffereast

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024