Problem/Motivation

When accessing the user salesforce mapping page (/user/{uid}/salesforce) without an active Salesforce OAuth token (e.g., token revoked, expired, or not configured), the site crashes with a fatal error:

  OAuth\Common\Storage\Exception\TokenNotFoundException: in
  Drupal\salesforce\Storage\SalesforceAuthTokenStorage->retrieveAccessToken()

Steps to reproduce

1. Have a user with Salesforce mapped objects
2. Revoke or don't configure Salesforce OAuth token
3. Navigate to /user/{uid}/salesforce
4. Page crashes with TokenNotFoundException

Stack trace-

SalesforceAuthTokenStorage->retrieveAccessToken()
SalesforceAuthProviderPluginBase->getAccessToken()
SalesforceAuthProviderPluginBase->getInstanceUrl()
MappedObject->getSalesforceUrl()
SalesforceLinkItemList->computeValue()
MappedObjectList->buildRow()

Proposed resolution

Wrap the getSalesforceUrl() call in SalesforceLinkItemList::computeValue() with a try-catch block to gracefully handle TokenNotFoundException. When the exception is caught, display the SFID without a link instead of crashing.

Comments

hitesh-jain created an issue. See original summary.

  • aaronbauman committed 46193835 on 5.1.x
    Fix #3563593 - TokenNotFoundException in SalesforceLinkItemList crashes...
aaronbauman’s picture

Status: Needs review » Fixed

Fixed with slightly different approach

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • aaronbauman committed 46193835 on sniff-test
    Fix #3563593 - TokenNotFoundException in SalesforceLinkItemList crashes...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.