Populate Cache fails

Hello, 

I'm trying to populate a cache with the results of a service call, but when the flow attempts to store the value I get this error. 

error.class state type error Identifier 

Properties

java.lang.ClassCastException
PROXY_REQ_FLOW
ErrorPoint
class com.apigee.flow.Variables cannot be cast to class com.apigee.entities.info.TargetInfo (com.apigee.flow.Variables and com.apigee.entities.info.TargetInfo are in unnamed module of loader 'app')
fault

 

AMetelski_1-1641313226950.png

 

 

 

0 8 451
8 REPLIES 8

Hi, sorry about that error message. That does not sound particularly helpful. 

Can you show your PopulateCache policy configuration please?

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PopulateCache continueOnError="false" enabled="true" name="pc-access-token">
    <DisplayName>pc-access-token</DisplayName>
    <CacheResource>defaultCustomer</CacheResource>
    <CacheKey>
        <KeyFragment>token</KeyFragment>
    </CacheKey>
    <Scope>Exclusive</Scope>
    <ExpirySettings>
        <TimeoutInSec>60</TimeoutInSec>
    </ExpirySettings>
    <Source>accessToken</Source>
</PopulateCache>

 

And here is the extract variable right before the PC. 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables continueOnError="false" enabled="true" name="ev-login-response">
    <DisplayName>ev-login-response</DisplayName>
    <Properties/>
    <Source>loginResponse</Source>
    <JSONPayload>
        <Variable name="accessToken" type="string">
            <JSONPath>$.access_token</JSONPath>
        </Variable>
        <Variable name="apiUrl" type="string">
            <JSONPath>$.instance_url</JSONPath>
        </Variable>
    </JSONPayload>
</ExtractVariables>

Wow, that looks pretty basic. I am surprised you are having trouble with that. Let me try it here.

EDIT

OK I tried ... basically the same thing from here and... it just works. Attached please find a working API Proxy.

It does this:

  • check the cache for a stored value
  • if none is found

    • Use ServiceCallout to invoke an external system, getting a JSON response
    • Use ExtractVariables to extract a few fields from the response.
    • Use PopulateCache to load one of those values into the cache
    • Use AssignMessage to load the cached value into a well-known variable.
  • invoke a backend endpoint
  • in the response, insert the cached value as a header

 

Yeah, it's pretty basic. The issue ended up being in my assign message policy earlier in the flow.

Besides setting continueOnError = false Is there anything else I can do to make sure exceptions are bubbling up sooner?

I'd advise you to just omit continueOnError completely. It defaults to false, which is usually what you want. 

And ... nope, nothing further for you to do.  Setting continueOnError to false , or omitting it completely, is what you need to do to let exceptions surface at the earliest possible point. 

I encountered the same issue, do you mind sharing what you did to fix it?

@joe_zennioptica, I don't recall the exact fix, but there was a missing configured assign message before the cache policy that was causing the fault. 

I had same issue. As mentioned above, root cause was in the assign variable. In my case I was trying to assign target.copy.pathsuffix in the proxy with no target.

Once that part had been commented, everything started to work

It is still unclear why

- same code works well in Edge

- Issue is caused by incorrectly assigned variable, but the error actually happens only if there is a populate cache activity after such assign. 

Still the error makes some sense --  looks like target variable was not initialized without having actual target in the proxy, so assigning something there was incorrect

Hope this helps