module-shipper icon indicating copy to clipboard operation
module-shipper copied to clipboard

Error: Running "Synchronize with ShipperHQ" in Magento admin

Open pbaum83 opened this issue 5 years ago • 3 comments

Hello,

We recently upgraded our M2 module and the module appears to be retrieving an auth token properly with our API credentials, but there is an issue when running the synchronize function.

vendor/shipperhq/module-shipper/src/Model/Synchronizer.php Line: 221

This line appears to be getting an invalid response from the API: $resultSetArray[] = $this->send($synchronizeUrl, $credentials);

array (
   'json_request' => false,
   'url' => 'https://api.shipperhq.com/v1//attributes/get',
   'response' => '<!doctype html><html lang="en"><head><title>HTTP Status 400 – Bad Request</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 400 – Bad Request</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Description</b> The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).</p><hr class="line" /><h3>Apache Tomcat/8.5.32</h3></body></html>',
 )

I haven't changed anything in the module to affect this and not sure what the issue is with the request since I can't seem to access the REST API docs.

Here is the object information that is posting and url (https://api.shipperhq.com/v1//attributes/get)

ShipperHQ\WS\Rate\Request\InfoRequest Object
(
    [credentials] => ShipperHQ\WS\Shared\Credentials Object
        (
            [password] => ** hidden ***
            [apiKey] => ** hidden ***
        )

    [siteDetails] => ShipperHQ\WS\Shared\SiteDetails Object
        (
            [ecommerceCart] => Magento 2 Community
            [ecommerceVersion] => 2.3.4
            [websiteUrl] => http://development.myhost.com/
            [environmentScope] => LIVE
            [appVersion] => 20.39.7
            [ipAddress] => 
        )
)

Let me know if anymore details would be helpful.

Thanks

pbaum83 avatar Jan 28 '21 21:01 pbaum83

One more detail to add to this, there was an issue with the auth token request failing and it was fixed by downgrading the " lcobucci/jwt" library to version 3.3.

composer require lcobucci/jwt:3.3

Reference (this was the initial error): https://stackoverflow.com/questions/65009120/implicit-conversion-of-keys-from-strings-is-deprecated-please-use-inmemory-or-l

Also when the shipperhq module is enabled we noticed that when saving system configurations and products we consistently receive this error (disabling the module resolves the error): "Something went wrong while saving this configuration: Unable to serialize value. Error: Malformed UTF-8 characters, possibly incorrectly encoded"

pbaum83 avatar Jan 28 '21 21:01 pbaum83

Thanks for the details, @pbaum83 ! I'll get this scheduled to be reviewed so that any needed changes can be made. I'm glad to hear you have an effective workaround in place as you described.

wsadasmit avatar Jan 28 '21 23:01 wsadasmit

Just an update, the issue with lcobucci/jwt:3.4 was causing an issue which I resolved and the other problem appears to have been related to how environment variables are set in Magento on our system which when referenced via the function getConfigValue in vendor/shipperhq/module-shipper/Helper/Data.php are not currently returning the values we provided.

I will be looking into this a bit more with our devops team and will update if there is another method that might work better.

pbaum83 avatar Feb 11 '21 00:02 pbaum83