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).
![[] error message](/files/issues/2025-09-05/searchstax-no-app-error-unhandled.png)
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.

| Comment | File | Size | Author |
|---|---|---|---|
| #2 | no-app-account-breaks-migration-form-3545168-2.patch | 2.23 KB | wolffereast |
| searchstax-no-app-error-handled.png | 21 KB | wolffereast | |
| searchstax-no-app-error-unhandled.png | 27.03 KB | wolffereast |
Issue fork searchstax-3545168
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
Comment #2
wolffereast commentedAdding an interim patch which fixes the form for now
Comment #5
drunken monkeyThanks a lot for reporting this problem! I can reproduce it in the latest dev version, too.
As you say,
[]is definitely a valid response and we should treat it as such. I’m pretty sure just fixing the method in theApiclass should be safe, I cannot imagine any code relying on this faulty behavior.Unfortunately, your patch does not apply for me, but this merge request should implement a complete solution:
Api::sendApiRequest()to not treat a[]response as a failed request.MigrateServerFormto display a helpful message when an account has no apps.Please give it a try and tell me whether this works for you.
And thanks again, in any case!
Comment #7
drunken monkeyDoes anyone still want to test or review this MR?
Comment #8
carolpettirossi commentedI couldn't apply the patch on 1.8.1
Comment #9
carolpettirossi commentedComment #10
drunken monkeyThanks for reporting!
I rebased the MR, please try again.
Comment #11
sophie.skConfirming that the updated patch applies cleanly against version 1.10.0, and resolves the issues I've spotted.
Namely, this resolves the issue #3550829: Version Check fails when one of the Accounts doesn't have an App configured yet - will post there too.
Comment #13
drunken monkeyThanks a lot for your feedback, glad to hear this worked for you!
Merged. Thanks again, everyone!
Comment #15
drunken monkey