magento / graphql-ce

[ARCHIVED] Please use magento/magento2 project
https://github.com/magento/magento2
Open Software License 3.0
131 stars 156 forks source link

Notice: Undefined index: street #1033

Closed TomashKhamlai closed 5 years ago

TomashKhamlai commented 5 years ago

Preconditions (*)

  1. The customer has an active cart

Steps to reproduce (*)

  1. Set shipping address without street parameter
    mutation {
    setShippingAddressesOnCart(
    input: {
      cart_id: "02GYdVCktyqGo8LfEkoBwPbkCLxt3lL9"
      shipping_addresses: [
        {
          address: {
            country_code: "US"
            firstname: "John"
            lastname: "Doubledo"
            telephone: ""
            save_in_address_book: true
            city: "Culver city"
          }
        }
      ]
    }
    ) {
    cart {
      email
      shipping_addresses {
        postcode
        firstname
        lastname
        telephone
        selected_shipping_method {
          carrier_code
          method_code
        }
        available_shipping_methods {
          carrier_code
          method_code
        }
      }
    }
    }
    }

Expected result (*)

  1. Required parameter "street" is missing

Actual result (*)

  1. Internal Server Error
    {
    "errors": [
    {
      "debugMessage": "Notice: Undefined index: street in /var/www/html/graphqlce/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php on line 93",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "setShippingAddressesOnCart"
      ]
    }
    ],
    "data": {
    "setShippingAddressesOnCart": null
    }
    }
TomashKhamlai commented 5 years ago

Just covered - not fixed.

lenaorobei commented 5 years ago

Hi @TomashKhamlai. The schema looks following:

input CartAddressInput {
 firstname: String!
 lastname: String!
 company: String
 street: [String!]!
 city: String!
 region: String
 postcode: String
 country_code: String!
 telephone: String!
 save_in_address_book: Boolean
}

street is required input parameter and the case that validation does not properly happening shows that it is a framework bug. Such validation should not happen in resolvers and such test cases are redundant.

Closing this PR since the framework bug is assigned to the internal team.