forrest icon indicating copy to clipboard operation
forrest copied to clipboard

What throws the MissingResourceException?

Open roblesterjr04 opened this issue 6 years ago • 6 comments
trafficstars

I am working with a salesforce staging/sandbox environment. I've never seen this exception thrown in production but we get it intermittently with sandbox. There's no consistency in when we get it or under what conditions. Can you shed some light on the context of the exception? I kind of understand it has to do with the storage repo for the token, but i don't understand under what conditions the repo is not available. Thanks!

Omniphx\Forrest\Exceptions\MissingResourceException: No resources available in /home/~*~*~*~/vendor/omniphx/forrest/src/Omniphx/Forrest/Repositories/ResourceRepository.php:36

roblesterjr04 avatar May 28 '19 21:05 roblesterjr04

The resource repo is just a cache of this request: Forrest::resources(); which tells the app which REST APIs it has access to. More info here: https://github.com/omniphx/forrest#api-requests

After storing "resources", the library allows you to call any of those resources methods using the magic __call() method. If Salesforce decides to create a new API called EinsteinPrediction or something similar. You'll be able to consume it with Forrest::EinsteinPrediction().

That exception is basically saying for some reason there is nothing in your storage that has the name "resource". Maybe it's possible the cache or session has been cleared?

I included the exception message to provide more information than a null pointer exception, but seems like a better solution is for the library to retry the resources() request if it doesn't exist. If cache clearing turns out to be the case, I'll flag this as an enhancement.

omniphx avatar May 28 '19 21:05 omniphx

Do you have any reason to believe that this will only occur to me in SandBox environments? Like I said, I've never encountered it in production.

roblesterjr04 avatar May 29 '19 16:05 roblesterjr04

I would test the Forrest::resources(); in your sandbox environment. If it returns results, then my guess is that something is happening in your Session/Cache settings.

Does this happen all the time or is it intermittent?

omniphx avatar May 29 '19 17:05 omniphx

Intermittent in the sandbox environment. On May 29, 2019, 1:31 PM -0400, Marty [email protected], wrote:

I would test the Forrest::resources(); in your sandbox environment. If it returns results, then my guess is that something is happening in your Session/Cache settings. Does this happen all the time or is it intermittent? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

roblesterjr04 avatar May 29 '19 17:05 roblesterjr04

Confirmed its not just sandbox - will troubleshoot.

roblesterjr04 avatar May 31 '19 18:05 roblesterjr04

I've been seeing the same issue in the last week or two and it may be related to issue #197. I'm seeing sporadic 411 length required errors on \Forrest::authenticate(); and then after this occurs I start receiving the missing Resource Exception errors.

bgenoa avatar Jun 12 '19 16:06 bgenoa