After the merge is completed, the merge service will attempt to remove the branch from the application included in the request. For Deployment Manager this will be the pipeline's target application, or the testing application (If one is specified). This error, along with a successful merge, suggests that saving the application record failed for some reason.
Make sure that you are following the guidance from this article. The development application which is used for managing branches should not be used for either the pipeline's target or testing application.
This error will be raised if the specified application both includes the branch being merged and is locked.
Try saving the application directly to ensure that it is valid.