Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Handle failed app installation
Maciej Korycinskiaa41f6f315e8
diff --git a/saleor/app/installation_utils.py b/saleor/app/installation_utils.pyindex e18780508f..9f9c488c72 100644--- a/saleor/app/installation_utils.py+++ b/saleor/app/installation_utils.py@@ -2,7 +2,6 @@ import requestsfrom django.contrib.sites.models import Sitefrom django.core.exceptions import ValidationErrorfrom django.core.validators import URLValidator-from django.db import transactionfrom .models import App, AppInstallationfrom .types import AppType@@ -30,7 +29,6 @@ def validate_manifest_fields(manifest_data):raise ValidationError({"tokenTargetUrl": "Incorrect format."})def install_app(app_installation: AppInstallation, activate: bool = False,):@@ -56,7 +54,12 @@ def install_app()app.permissions.set(app_installation.permissions.all())token = app.tokens.create(name="Default token")- send_app_token(- target_url=manifest_data.get("tokenTargetUrl"), token=token.auth_token- )++ try:+ send_app_token(+ target_url=manifest_data.get("tokenTargetUrl"), token=token.auth_token+ )+ except requests.RequestException as e:+ app.delete()+ raise ereturn app