saleor/saleor

Bug: KeyError: 'status' raised in orderBulkCreate mutation

Open

#14506 opened on Oct 27, 2023

View on GitHub
 (1 comment) (1 reaction) (0 assignees)Python (19,887 stars) (5,278 forks)batch import
bughelp wantedmerchantorder

Description

What are you trying to achieve?

Create many orders using the orderBulkCreate mutation.

Steps to reproduce the problem

Example query (needs authorization and MANAGE_ORDERS permission):

mutation orderBulkCreate {
  orderBulkCreate(
    errorPolicy: REJECT_EVERYTHING
    stockUpdatePolicy: SKIP
    orders: [
      {
        channel: "default-channel",
        createdAt: "2023-10-17T12:16:28.866236+00:00",
        user: {
          email: "test@example.com"},
        currency: "USD",
        billingAddress: {
          firstName: "test",
          lastName: "test",
          streetAddress1: "test",
          postalCode: "12-123",
          city: "test",
          country: PL
        },
        languageCode: EN,
        lines: []
      }
    ]
  ) {
    count
    results {
      order {
        id
      }
      errors {
        path
        message
      }
    }
    errors {
      path
      message
    }
  }
}

What did you expect to happen?

The mutation should not crash with a Python exception. Since status was initially marked as a required field in the RFC, but wasn't implemented as such, the solution here would be:

  • Mark the field as required in API (required=True flag in the input field definition)
  • Add an entry in the changelog informing that this change was made and that it is breaking (because the field becomes required, so if anyone is using it already, they'll have to adjust their queries). We can make a breaking change here since this API is still in preview.

Logs

No response

Environment

Saleor version: 3.14 OS and version: …

Contributor guide