order_number should not be marked required

Created on 24 June 2019, over 5 years ago
Updated 18 September 2024, 2 months ago

While trying to create an Order through JSON:API I got an error pushing me to provide the order_number as part of the request.
After some discussion with mikelutz and mglaman on Slack, the suggested solution was to make the order_number not required for draft orders and then add a custom validation constraint which marks it required for the other states.

The expectation would be to have the same behavior as if an Order is placed through the site where the order_number is set by the EventSubscriber to be the same as the order_id.

Extract of the body of JSON:API POST request:

{
  "data": {
    "type": "commerce_order--default",
    "attributes": {
    "mail": "dscl@example.com",
    "state": "draft"
  },
  (...)
}

Extract of the JSON:API error:

(...)
"title": "Unprocessable Entity",
"status": "422",
"detail": "order_number: This value should not be null.",
"source": {
  "file": "/var/www/devbrains/pubfactory-d9/web/core/modules/jsonapi/src/Entity/EntityValidationTrait.php",
  "line": 59,
  "pointer": "/data/attributes/order_number"
},
(...)
๐Ÿ› Bug report
Status

Needs review

Version

2.0

Component

Order

Created by

๐Ÿ‡ฆ๐Ÿ‡บAustralia dscl Melbourne, VIC

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vinay.p

    vinay.p โ†’ made their first commit to this issueโ€™s fork.

  • Pipeline finished with Failed
    3 months ago
    Total: 405s
    #281167
  • Pipeline finished with Failed
    3 months ago
    Total: 450s
    #281224
  • Status changed to Needs review 2 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vinay.p
  • Pipeline finished with Failed
    about 1 month ago
    Total: 553s
    #319990
  • Pipeline finished with Failed
    about 1 month ago
    Total: 609s
    #319997
  • Pipeline finished with Failed
    about 1 month ago
    Total: 1195s
    #320020
  • Pipeline finished with Success
    about 1 month ago
    Total: 695s
    #320053
  • Pipeline finished with Failed
    about 1 month ago
    Total: 591s
    #320986
  • Pipeline finished with Success
    about 1 month ago
    Total: 986s
    #320993
  • Pipeline finished with Success
    about 1 month ago
    Total: 718s
    #322240
  • Pipeline finished with Success
    about 1 month ago
    Total: 948s
    #322247
Production build 0.71.5 2024