omniphx / forrest

A Laravel library for Salesforce
https://omniphx.github.io/forrest/
MIT License
259 stars 120 forks source link

failed exception handling when " The users password has expired" #261

Closed Shaws-WD closed 4 years ago

Shaws-WD commented 4 years ago

(btw, thanks so much for forREST for use by our non-profit!)

Short version I am encountering a problem with Forrest v2.6.0 under Laravel 5.4 The problem occurs with the Forrest call

$response = Forrest::query($SOQL)

when the users password expired.

I have that Forrest call in a try/catch structure

try { $response = Forrest::query($SOQL);
} catch (Exception $e) { $synchException = $e; }

However when encountering this error, Forrest does NOT return an exception (ie. nothing detected by 'catch') Instead the error is silent and subsequent code fails

I am able to see the error only when I remove the try/catch and find an error logged by Laravel (as shown below)

In Client.php line 830: [
{
"message": "The users password has expired, you must call SetPassword before attempting any other API operations",
"errorCode": "INVALID_OPERATION_WITH_EXPIRED_PASSWORD"
}
]

In RequestException.php line 113: Client error: GET https://windowdressers--pcopy.my.salesforce.com/services /data/v49.0/query?q=SELECT+id%2CRecordTypeId%2CWDDB_poid__c%2CLastModifiedD ate%2CWDDB_first_name__c%2CWDDB_last_name__c%2CWDDB_phone_pref__c%2CWDDB_em ail_pref__c%2CName%2CBillingStreet%2CBillingCity%2CBillingState%2CBillingPo stalCode%2CWDDB_comments__c+FROM+Account++where+RecordTypeId+%3D+%270123i00 0000qGcrAAE%27AND+LastModifiedDate+%3E2020-07-29T11%3A57%3A03-04%3A00 resu
lted in a 403 Forbidden response:
[{"message":"The users password has expired, you must call SetPassword befo
re attempting any other API operations","erro (truncated...)

omniphx commented 4 years ago

Hi @Shaws-WD, unfortunately, I'm not able to reproduce this. Getting an exception thrown for all types of 400 responses. Even went so far as expiring all passwords in my dev org to see what happens. Screen Shot 2020-10-15 at 5 16 08 PM

I'd suggest trying to upgrade from 2.6

Shaws-WD commented 4 years ago

Thanks SO much for trying to replicate.

I'd suggest trying to upgrade from 2.6 I'm intending to do that but have been limited by our Laravel version. Your comments raised my priority of working through the Laravel upgrades