Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Extend checkout external shipping id max length (#18422)

Filip Owczareka767eea219a9
diff --git a/saleor/checkout/migrations/0080_alter_checkout_external_shipping_method_id.py b/saleor/checkout/migrations/0080_alter_checkout_external_shipping_method_id.py
new file mode 100644
index 0000000000..387e414b95
--- /dev/null
+++ b/saleor/checkout/migrations/0080_alter_checkout_external_shipping_method_id.py
@@ -0,0 +1,19 @@
+# Generated by Django 4.2.20 on 2025-11-03 08:42
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("checkout", "0079_alter_checkoutline_prior_unit_price_amount_and_more"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="checkout",
+ name="external_shipping_method_id",
+ field=models.CharField(
+ blank=True, default=None, editable=False, max_length=1024, null=True
+ ),
+ ),
+ ]
diff --git a/saleor/checkout/migrations/0081_merge_20251103_0924.py b/saleor/checkout/migrations/0081_merge_20251103_0924.py
new file mode 100644
index 0000000000..606e808452
--- /dev/null
+++ b/saleor/checkout/migrations/0081_merge_20251103_0924.py
@@ -0,0 +1,12 @@
+# Generated by Django 5.2.5 on 2025-11-03 09:24
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("checkout", "0080_alter_checkout_external_shipping_method_id"),
+ ("checkout", "0080_merge_20250527_1210"),
+ ]
+
+ operations = []
diff --git a/saleor/checkout/models.py b/saleor/checkout/models.py
index c3342bbf88..d6dc6922cf 100644
--- a/saleor/checkout/models.py
+++ b/saleor/checkout/models.py
@@ -87,7 +87,7 @@ class Checkout(models.Model):
max_length=255, null=True, default=None, blank=True, editable=False
)
external_shipping_method_id = models.CharField(
- max_length=512, null=True, default=None, blank=True, editable=False
+ max_length=1024, null=True, default=None, blank=True, editable=False
)
collection_point = models.ForeignKey(
diff --git a/saleor/graphql/checkout/tests/mutations/test_checkout_delivery_method_update.py b/saleor/graphql/checkout/tests/mutations/test_checkout_delivery_method_update.py
index 03b62f7b42..2b585399fc 100644
--- a/saleor/graphql/checkout/tests/mutations/test_checkout_delivery_method_update.py
+++ b/saleor/graphql/checkout/tests/mutations/test_checkout_delivery_method_update.py
@@ -385,6 +385,59 @@ def test_checkout_delivery_method_update_external_shipping(
assert data["checkout"]["deliveryMethod"]["id"] == method_id
[email protected]("saleor.webhook.transport.synchronous.transport.send_webhook_request_sync")
+@patch(
+ "saleor.graphql.checkout.mutations.checkout_delivery_method_update."
+ "clean_delivery_method"
+)
+def test_checkout_delivery_method_update_external_shipping_long_external_id(
+ mock_clean_delivery,
+ mock_send_request,
+ api_client,
+ checkout_with_item_for_cc,
+ settings,
+ shipping_app,
+ channel_USD,
+):
+ checkout = checkout_with_item_for_cc
+ query = MUTATION_UPDATE_DELIVERY_METHOD
+ mock_clean_delivery.return_value = True
+
+ settings.PLUGINS = ["saleor.plugins.webhook.plugin.WebhookPlugin"]
+ response_method_id = "A" * 700 # External ID longer than 512 characters
+ response_shipping_name = "Provider - Economy"
+ response_shipping_price = "10"
+ mock_json_response = [
+ {
+ "id": response_method_id,
+ "name": response_shipping_name,
+ "amount": response_shipping_price,
+ "currency": "USD",
+ "maximum_delivery_days": "7",
+ }
+ ]
+ mock_send_request.return_value = mock_json_response
+
+ method_id = graphene.Node.to_global_id(
+ "app", f"{shipping_app.id}:{response_method_id}"
+ )
+
+ response = api_client.post_graphql(
+ query, {"id": to_global_id_or_none(checkout), "deliveryMethodId": method_id}
+ )
+ data = get_graphql_content(response)["data"]["checkoutDeliveryMethodUpdate"]
+ checkout.refresh_from_db()
+
+ errors = data["errors"]
+
+ assert not errors
+ assert (
+ PRIVATE_META_APP_SHIPPING_ID not in checkout.metadata_storage.private_metadata
+ )
+ assert checkout.external_shipping_method_id == method_id
+ assert len(checkout.external_shipping_method_id) > 900
+
+
@mock.patch("saleor.webhook.transport.synchronous.transport.send_webhook_request_sync")
@patch(
"saleor.graphql.checkout.mutations.checkout_delivery_method_update."