magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

V1/carts/mine/billing-address returning %fieldName is a required field. #7299

Closed alessandrozucca closed 4 years ago

alessandrozucca commented 8 years ago

Preconditions

  1. Magento EE 2.1.1
  2. PHP 7.0.12
  3. Mysql Ver 14.14 Distrib 5.6.33-79.0, for Linux (x86_64) using 6.2

Steps to reproduce

{"cartId":"190488","address":{"countryId":"GB","regionId":"0","region":"","street":["54 Carnegie Court",""],"company":"","telephone":"0165 4569 8754","fax":"","postcode":"AB1C 2DF","city":"SomeCity","firstname":"Bob","lastname":"White","save_in_address_book":1,"saveInAddressBook":null}}

Note that this api endpoint is used by the module ebizmarts/sagepaysuite for the payment option SagePay

Actual result

{
  "message": "%fieldName is a required field.",
  "parameters": {
    "fieldName": "cartId"
  },
  "trace": "
  #0 magento/framework/Webapi/ServiceInputProcessor.php(131): Magento\\Framework\\Webapi\\ServiceInputProcessor->processInputError(Array)\n
  #1 magento/module-webapi/Controller/Rest/InputParamsResolver.php(101): Magento\\Framework\\Webapi\\ServiceInputProcessor->process('Magento\\\\Quote\\\\A...', 'assign', Array)\n
  #2 magento/module-webapi/Controller/Rest.php(299): Magento\\Webapi\\Controller\\Rest\\InputParamsResolver->resolve()\n
  #3 magento/module-webapi/Controller/Rest.php(216): Magento\\Webapi\\Controller\\Rest->processApiRequest()\n
  #4 magento/framework/Interception/Interceptor.php(146): Magento\\Webapi\\Controller\\Rest->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n
  #5 /var/www/qa-mowdirect.webpipeline.net/shared/var/generation/Magento/Webapi/Controller/Rest/Interceptor.php(39): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callPlugins('dispatch', Array, Array)\n
  #6 magento/framework/App/Http.php(135): Magento\\Webapi\\Controller\\Rest\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n
  #7 magento/framework/App/Bootstrap.php(258): Magento\\Framework\\App\\Http->launch()\n
  #8 /var/www/qa-mowdirect.webpipeline.net/releases/20161102175610/pub/index.php(37): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http))\n
  #9 {main}"
}

Note that cartId is in the payload but the parameter validation fails.

thdoan commented 7 years ago

@alessandrozucca may I know what the resolution was? We seem to be having a similar issue:

Request URL = V1/carts/mine/estimate-shipping-methods-by-address-id Request Payload = {addressId: "60"} Response = {"message":"%fieldName is a required field.","parameters": {"fieldName":"cartId"}

alessandrozucca commented 7 years ago

The issue wasn't resolved.

My current company, did send it to Magento via the "partners portal", the project I was working on then got blocked for other reasons and I didn't follow up with the issue.

If you are getting it too, then is definitely an issue that should be fixed.

collymore commented 7 years ago

We're getting the same issue. If logged in with a saved address then it fails with visible error message "cartId is a required field"

Steps to reproduce.

No other JS errors are shown on the checkout.

PHP 7.0.10 Current application mode: developer Magento : 2.1.6

Quick update: I've found it happens almost all the time on a second purchase, after a successful purchase and remaining logged in, when trying to make a second purchase it causes the issue. If I logout and back in I'm able to make a second purchase fine.

MikeSheward commented 7 years ago

I'm getting this error too, guest checkout is disabled and checking out as a registered user. It's trying to goto: /rest/default/V1/carts/mine/estimate-shipping-methods-by-address-id Req payload: {addressId: "13"}

but that returns "message": "%fieldName is a required field.", "parameters": { "fieldName": "cartId" }

Stacktrace { "message": "%fieldName is a required field.", "parameters": { "fieldName": "cartId" }, "trace": "#0 \/home\/magento\/public_html\/vendor\/magento\/framework\/Webapi\/ServiceInputProcessor.php(131): Magento\\Framework\\Webapi\\ServiceInputProcessor->processInputError(Array)\n#1 \/home\/magento\/public_html\/vendor\/magento\/module-webapi\/Controller\/Rest\/InputParamsResolver.php(101): Magento\\Framework\\Webapi\\ServiceInputProcessor->process('Magento\\\\Quote\\\\A...', 'estimateByAddre...', Array)\n#2 \/home\/magento\/public_html\/vendor\/magento\/module-webapi\/Controller\/Rest.php(299): Magento\\Webapi\\Controller\\Rest\\InputParamsResolver->resolve()\n#3 \/home\/magento\/public_html\/vendor\/magento\/module-webapi\/Controller\/Rest.php(216): Magento\\Webapi\\Controller\\Rest->processApiRequest()\n#4 \/home\/magento\/public_html\/var\/generation\/Magento\/Webapi\/Controller\/Rest\/Interceptor.php(37): Magento\\Webapi\\Controller\\Rest->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#5 \/home\/magento\/public_html\/vendor\/magento\/framework\/App\/Http.php(135): Magento\\Webapi\\Controller\\Rest\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#6 \/home\/magento\/public_html\/vendor\/magento\/framework\/App\/Bootstrap.php(258): Magento\\Framework\\App\\Http->launch()\n#7 \/home\/magento\/public_html\/pub\/index.php(53): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http))\n#8 {main}" }

This behaviour is intermittent too (deleting the item from the cart and readding sometimes also solves this)

Any ideas? Thanks

MikeSheward commented 7 years ago

Any updates on this? Thanks

jugal-kishor commented 7 years ago

{"message":"%fieldName is a required field.","parameters":{"fieldName":"cartId"},"trace":"#0 \/home\ /daraway1\/public_html\/vendor\/magento\/framework\/Webapi\/ServiceInputProcessor.php(111): Magento\ \Framework\Webapi\ServiceInputProcessor->processInputError(Array)\n#1 \/home\/daraway1\/public_html \/vendor\/magento\/module-webapi\/Controller\/Rest.php(262): Magento\Framework\Webapi\ServiceInputProcessor-

process('Magento\\Checkou...', 'savePaymentInfo...', Array)\n#2 \/home\/daraway1\/public_html\/vendor \/magento\/module-webapi\/Controller\/Rest.php(160): Magento\Webapi\Controller\Rest->processApiRequest ()\n#3 \/home\/daraway1\/public_html\/var\/generation\/Magento\/Webapi\/Controller\/Rest\/Interceptor .php(24): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http) )\n#4 \/home\/daraway1\/public_html\/vendor\/magento\/framework\/App\/Http.php(115): Magento\Webapi \Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))\n#5 \/home \/daraway1\/public_html\/vendor\/magento\/framework\/App\/Bootstrap.php(258): Magento\Framework\App \Http->launch()\n#6 \/home\/daraway1\/public_html\/index.php(45): Magento\Framework\App\Bootstrap- run(Object(Magento\Framework\App\Http))\n#7 {main}"}

jugal-kishor commented 7 years ago

i got this error when i place order on frontend also i checked sales order in admin order showing is in peding. mean order showing in admin but not working on frontend

panneerselvam-vit commented 7 years ago

Hi

i fixed this issue. Below is the fix for this issue.

  1. pass cartId in the below js after line no. file : Magento_Checkout\web\js\model\shipping-rate-processor\customer-address.js

                storage.post(
                    resourceUrlManager.getUrlForEstimationShippingMethodsByAddressId(quote),
                    JSON.stringify({
                        addressId: address.customerAddressId,
            cartId: quote.getQuoteId()
                    }),
                    false
                )
  2. Prevent cartId param removal by adding a plugin for the below method

File : \Magento\Webapi\Controller\Rest\ParamsOverrider

plugin

public function aroundoverride(\Magento\Webapi\Controller\Rest\ParamsOverrider $ParamsOverrider,\Closure $proceed,array $inputData, array $parameters)
{
    if(isset($inputData['cartId'])){$cartid = $inputData['cartId'];}        
    $result = $proceed($inputData,$parameters);
    if(isset($cartid)){$result['cartId'] = $cartid;}
    return $result;     
}
ebaschiera commented 7 years ago

Hi @panneerselvam-vit , thanks for your fix! I found a little problem at checkout when adding a coupon code as a registered user. The coupon cannot be added due to the following error: Invalid type for value: "mine". Expected Type: "int".

So I modified the plugin like this:

public function aroundoverride(\Magento\Webapi\Controller\Rest\ParamsOverrider $ParamsOverrider, \Closure $proceed, array $inputData, array $parameters) {
    if (isset($inputData['cartId']) && (!isset($inputData['couponCode']) || !isset($inputData['coupon_code']))) {
            $cartid = $inputData['cartId'];
        }
        $result = $proceed($inputData, $parameters);
        if (isset($cartid)) {
            $result['cartId'] = $cartid;
        }
        return $result;
    }

Best regards.

idziakjakub commented 7 years ago

Hello,

I had the same issue on stage server, it appeared unexpectedly when client was testing orders. This project was tested on docker, vagrant and latest server and there was newer a problem with checkout page. I started to check @panneerselvam-vit fixes and I found that some folders has permissions only for user and group "root" (var/generation, var/di) and when I fixed permissions problem has solved.

magento-engcom-team commented 6 years ago

@alessandrozucca, thank you for your report. We've created internal ticket(s) MAGETWO-84524 to track progress on the issue.

ghost commented 5 years ago

Similar or identical github issues for this same error:

https://github.com/magento/magento2/issues/9744

https://github.com/magento/magento2/issues/7299

https://github.com/magento/magento2/issues/1443

https://github.com/magento/magento2/issues/5847

https://github.com/shipperhq/module-shipper/issues/27

https://github.com/magento/magento2/issues/6522

All related, tried every solution on all pages and still have the issue, including @sydekumf solution here: https://github.com/magento/magento2/issues/9744#issuecomment-347831102 this solution https://github.com/magento/magento2/issues/7299#issuecomment-305437174 this solution https://github.com/magento/magento2/issues/7299#issuecomment-327420755 and checked if this solution would apply but it didn't: https://github.com/magento/magento2/issues/5847#issuecomment-402379223

Issue MAGETWO-84524 is tracking it to some degree and still isn't fixed in Magento 2.3

How is this the most popular ecommerce store in the US if it doesn't even have a functioning checkout. This happens for me using authnet directpost regardless of what I do, guest checkout, or new, using stored address, or not. Only the error message will change at times, but it's always one of the error messages given in the links above.

Issue is as described, there is a quote_id in the quote table but it is not active. If I switch it manually to be active then it has duplicate foreign key when trying to replace the order. With active set to 0, get the cartId error.

The only solution anyone seems to say works 100% is buying a 3rd part module to do authorize.net payments which seems absurd, as paypal also doesn't work, citing invoice id errors.

gakonhd commented 5 years ago

Has anyone found the solution with this issue yet? I am using Magento 2..2.8 and I still have this problem

m2-assistant[bot] commented 5 years ago

Hi @GovindaSharma. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

GovindaSharma commented 5 years ago

dmcdindia1

GovindaSharma commented 5 years ago

i am working on this

gakonhd commented 5 years ago

Hi @GovindaSharma. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

  • [ ] 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 2. Verify that the issue is reproducible on 2.3-develop branchDetails- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure. - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • [ ] 3. Verify that the issue is reproducible on 2.2-develop branch. Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure. - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • [ ] 4. If the issue is not relevant or is not reproducible any more, feel free to close it.

Thank you for having people working on this. I am looking forward to the update of this version. Thank you again.

magento-engcom-team commented 5 years ago

Hi @gakonhd. Thank you for your request. I'm working on Magento 2.3-develop instance` to deploy test instance for you

gakonhd commented 5 years ago

Hi @gakonhd. Thank you for your request. I'm working on Magento 2.3-develop instance` to deploy test instance for you

Hi @magento-engcom-team , thank you for the update. I wonder if the fix will be applied to 2.2.8 version as well ?

pkavanaghjr commented 5 years ago

@gakonhd @magento-engcom-team

I am also looking for a solution to be released for v2.2.8, is that currently in development as well?

ladle3000 commented 5 years ago

Also urgently needing help with this. What fixes it?

ghost commented 5 years ago

This is what "fixed" it for me, just like a lot else broken in M2, if you want it to actually work you have to purchase a module, going m2 was a giant mistake. https://store.paradoxlabs.com/magento2-authorize-net-cim-payment-module.html

engcom-Charlie commented 4 years ago

Hello @alessandrozucca

I am not able to reproduce this issue on a fresh Magento 2.4-develop

Testing scenario:

  1. Go to the checkout after adding something to the basket
  2. Send a request to the REST endpoint V1/carts/mine/billing-address using the payload below {"cartId":"6","address":{"countryId":"GB","regionId":"0","region":"","street":["54 Carnegie Court",""],"company":"","telephone":"0165 4569 8754","fax":"","postcode":"AB1C 2DF","city":"SomeCity","firstname":"Bob","lastname":"White","save_in_address_book":1,"saveInAddressBook":null}}

Result: 200 OK success image

Could you add detailed steps to reproduce this issue in your case?

engcom-Charlie commented 4 years ago

We are closing this issue due to inactivity. If you'd like to update it, please reopen the issue.