Failing to push applications to downstream project space

We are failing to push applications from an upstream project space to downstream project space on a local instance of CommCare. We are getting the following error:

Hi, Niko.

Could you please do the following:

  • Grab the (downstream) application's ID from the URL (when on the page in the screenshot)
  • Enter the python terminal (cchq monolith django-manage shell)
  • Execute the following code with the <app_id> being the ID you see in the URL (note that it's a string value in the code):
from corehq.apps.app_manager.models import LinkedApplication
linked_app = LinkedApplication.get("<app_id>")

Please verify that linked_app.upstream_app_id is indeed the app id of the upstream application.

The result from the linked_app.upstream_app_id provides the following app_id: e617540bd4a14c1991c391cda979a0a9

From the web browser the app_id for the linked project application is different:


It seems when you converted the linked application to a standard application (because we provided the data as a linked application to you) before you linked it again to the local project, the conversion didn't happen 100% correctly.

My suggestion would be to do a relink, i.e.

  • convert the current downstream app into a standard application (to remove all linked data)
  • link the app again to the correct upstream app

Run the following code in the python terminal:

from corehq.apps.linked_domain.applications import unlink_app
from corehq.apps.app_manager.models import LinkedApplication

linked_app = LinkedApplication.get("<downstream_app_id>")

(For interest, you can check out here what happens when you convert a LinkedApplication to an Application)

There is a management command that you can also use to unlink an app, called unlink_apps, but I'm almost certain it will not work in this particular case, since the linked_app.upstream_app_id is an ID of an application that does not exist in your environment.

To link the app again to the upstream app in your environment, run the following management command:
link_apps <upstream_app_id> <downstream_app_id>

When you're done, please check the same linked_app.upstream_app_id as you did before and verify that it's the same as the actual upstream app in the web browser.

There seems to be a syntax error on this command:

link_apps <upstream_app_id> <downstream_app_id>

Oh, the link_apps management command needs to be executed outside of the python session (sorry, I wasn't clear about that point), e.g,

cchq monolith django-manage link_apps <upstream_id> <downstream_id>

Thanks for the clarification. app_id values are now matching.


Can you confirm whether your initial problem is thus solved?

Yes, users have confirmed that the issue has been resolved.

Thanks for the quick assist.