Unexpected error when configuring Federated Search Web Part

Problem

When opening the properties pane of the Federated Search web part an error message is shown:

ERROR: Unexpected error

Unable to perform requested action. Please check your SharePoint and Confluence log for more error details. The error message reported was: There was an exception in the Database. Please retry your operation and if the problem persists, contact an administrator.

The result source drop down is empty as well.

Solution

The application pool account of the web application that you are trying to use the federated search web part in needs access to the search database. Otherwise the list of result sources cannot be retrieved which leads to the red error message shown in the screenshot above.

Unfortunately the only possibility to fix this is to manually adjust the permissions on the SharePoint search database. The application pool account has to be added with role db_owner to the search database (see warning below) to check that this indeed fixes the error. The error should be immediately gone, no iisreset or restart is necessary, just a page reload.

Check that the app pool account has access to the search database and if not grant it the permissions necessary.

Modifying SharePoint database permissions directly is not supported for production farms. The missing permission points to something that is broken in the farm. There might be better ways to fix this depending on your environment.

The role db_owner is granting more permissions to the application pool account than necessary. Refer to the infrastructure documentation of your farm to determine the correct role; db_owner basically just makes it work at the cost of making your farm less "least privileged".