Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: promotionRuleCreate returns ValueError while other mutations in the same case return GRAPHQL_ERROR #13698

Closed
szczecha opened this issue Aug 16, 2023 · 1 comment
Labels
bug merchant Merchant Experience team topics promotions triage

Comments

@szczecha
Copy link
Member

What are you trying to achieve?

I want to have the same way of handling incorrect parameter id in promotion mutations

Steps to reproduce the problem

  1. Create a promotion with a rule
  2. Use promotion rule id in mutation promotionRuleCreate
    Response
{
  "errors": [
    {
      "message": "Cannot assign \"<PromotionRule: PromotionRule object (a798c8a6-6c57-4688-9fd9-682853f58f2a)>\": \"PromotionRule.promotion\" must be a \"Promotion\" instance.",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "promotionRuleCreate"
      ],
      "extensions": {
        "exception": {
          "code": "ValueError",
          "stacktrace": [
            "Traceback (most recent call last):",
            "  File \"/usr/local/lib/python3.9/site-packages/graphql/execution/executor.py\", line 452, in resolve_or_error",
            "    return executor.execute(resolve_fn, source, info, **args)",
            "  File \"/usr/local/lib/python3.9/site-packages/graphql/execution/executors/sync.py\", line 16, in execute",
            "    return fn(*args, **kwargs)",
            "  File \"/app/saleor/graphql/core/mutations.py\", line 536, in mutate",
            "    response = cls.perform_mutation(root, info, **data)",
            "  File \"/app/saleor/graphql/core/mutations.py\", line 809, in perform_mutation",
            "    instance = cls.construct_instance(instance, cleaned_input)",
            "  File \"/app/saleor/graphql/core/mutations.py\", line 502, in construct_instance",
            "    f.save_form_data(instance, data)",
            "  File \"/usr/local/lib/python3.9/site-packages/django/db/models/fields/__init__.py\", line 910, in save_form_data",
            "    setattr(instance, self.name, data)",
            "  File \"/usr/local/lib/python3.9/site-packages/django/db/models/fields/related_descriptors.py\", line 215, in __set__",
            "    raise ValueError(",
            "ValueError: Cannot assign \"<PromotionRule: PromotionRule object (a798c8a6-6c57-4688-9fd9-682853f58f2a)>\": \"PromotionRule.promotion\" must be a \"Promotion\" instance."
          ]
        }
      }
    }
  ],
  "data": {
    "promotionRuleCreate": null
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 0,
      "maximumAvailable": 50000
    }
  }
}

What did you expect to happen?

In promotionUpdate mutation when I pass the promotion rule Id instead of the promotion Id I get GRAPHQL_ERROR

{
  "data": {
    "promotionUpdate": {
      "errors": [
        {
          "field": "id",
          "message": "Must receive a Promotion id.",
          "code": "GRAPHQL_ERROR"
        }
      ],
      "promotion": null
    }
  },

The same error can be displayed for promotionRuleCreate

Logs

No response

Environment

Saleor version: branch feature/promotion-rules-crud
OS and version: …

@IKarbowiak
Copy link
Member

It turns out that it's a global problem. I created a separate ticket for that: #15466

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug merchant Merchant Experience team topics promotions triage
Projects
None yet
Development

No branches or pull requests

2 participants