- πΊπΈUnited States AaronBauman Philadelphia
I'm doing some cleanup on unsupported branches.
Please re-open this issue and update the version to 5.0.x-dev if this issue is still applicable to the latest release. - Status changed to Needs review
11 months ago 1:29am 9 February 2024 - πΊπΈUnited States gcb
Confirmed this is still a bug. Here's a stack trace of where the exception occurs when we make a call to
\Drupal\salesforce\Rest\RestClient::objectDescribe()
Promise.php:79, GuzzleHttp\Promise\Promise->wait() Client.php:189, GuzzleHttp\Client->request() HttpClientWrapper.php:40, Drupal\salesforce\Client\HttpClientWrapper->retrieveResponse() SalesforceJWTPlugin.php:177, Drupal\salesforce_jwt\Plugin\SalesforceAuthProvider\SalesforceJWTPlugin->requestAccessToken() SalesforceJWTPlugin.php:188, Drupal\salesforce_jwt\Plugin\SalesforceAuthProvider\SalesforceJWTPlugin->refreshAccessToken() SalesforceAuthProviderPluginManager.php:189, Drupal\salesforce\SalesforceAuthProviderPluginManager->refreshToken() RestClient.php:190, Drupal\salesforce\Rest\RestClient->isInit() RestClient.php:200, Drupal\salesforce\Rest\RestClient->apiCall() RestClient.php:512, Drupal\salesforce\Rest\RestClient->objectDescribe()
There's a call there:
throw Create::exceptionFor($this->result);
It's throwing an exception! And no one catches it. Walking it back up:
GuzzleHttp\Client->request()
states "@throws GuzzleException"That bring us into salesforce module code:
Drupal\salesforce\Client\HttpClientWrapper->retrieveResponse()
I think the trouble begins here, as this states:* @throws TokenResponseException
-- I don't think that includes a GuzzleException, so we probably need another "throws" here. Note that this comment is via @inheritdoc. Anyhow, the code doesn't acknowledge/handle the exception otherwise.SalesforceJWTPlugin->requestAccessToken()
also says it throws the token exception while ignoring it.After that, inherited comments start to acknowledge a MissingRefreshTokenException, but again, not handling them.
Based on the names and purposes of those functions, I do think it's reasonable for them to just throw exceptions -- they can't do the thing they want to do, which is to get a token!
This takes us back to `->isInit()`, which presumes to return a boolean telling you whether or not the RestClient is initialized. In this case, I think we can confidently say "it is not" and we know that because an attempt to refresh the access token causes an Exception to be thrown. We should catch this exception, log it, and return "FALSE".
TLDR: This is still an issue and @dspachos patch looks good to me. I'm not entirely sure why the change to `SalesforceJWTPlugin` is needed, but it seems like a clean and happy piece of code.
-
AaronBauman β
committed fbe246f0 on 5.0.x authored by
dspachos β
Issue #3224747 by dspachos: isInit() crashes when JWT is deactivated
-
AaronBauman β
committed fbe246f0 on 5.0.x authored by
dspachos β
- Status changed to Fixed
11 months ago 9:02pm 15 February 2024 - πΊπΈUnited States AaronBauman Philadelphia
Very helpful, thank you for unpacking all that, and thanks for the patch.
Committed to latest dev
Automatically closed - issue fixed for 2 weeks with no activity.