ResponseCache is returning Internal Server Error on response flow

We have a fairly simple proxy set up which I'm trying to add caching to. I've created a ResponseCache policy and added it to the default proxy endpoint as the last step in the Pre and Post flows

<ResponseCache async="false" continueOnError="false" enabled="true" name="Response-Cache">
    <DisplayName>Response Cache</DisplayName>
    <CacheKey>
        <KeyFragment ref="agreementId" type="string"/>
    </CacheKey>
    <ExpirySettings>
        <TimeoutInSec>600</TimeoutInSec>
    </ExpirySettings>
    <UseResponseCacheHeaders>true</UseResponseCacheHeaders>
    <ExcludeErrorResponse>true</ExcludeErrorResponse>
</ResponseCache>

When executed, the PreFlow works fine, but in the PostFlow, I'm seeing this error:

{
    "Envelope": {
        "encodingStyle": "http://schemas.xmlsoap.org/soap/encoding/",
        "Body": {
            "Fault": {
                "faultcode": "soap:Server",
                "faultstring": "java.lang.String cannot be cast to com.apigee.entities.info.EnvironmentInfo",
                "faultactor": {},
                "detail": {
                    "source": {
                        "errorcode": "Internal Server Error"
                    }
                }
            }
        }
    }
}

This fault isn't coming from our backend system - I can see the correct, expected response in the step right before ResponseCache (and setting `continueOnError` to `true` allows the backend's response through), but I can't find any additional info on why this error is happening.

0 1 108
1 REPLY 1

Figured this out. The issue was that we had extracted a variable from the headers called "environment" and didn't set a prefix for it. Apigee sets this variable automatically, though, and uses it to make the name of the execution environment available (see here). Of course, I read through the flow variables reference a dozen times trying to debug this, but my brain didn't click on that mismatch for some reason (probably because it's Friday). That, and it didn't cause any issues with any other policy. Lesson learned.