Hi Team,
We are creating our own keys/codes for APIGEE faults that can occur with in policies as we do not want to pass on the fault names as it is to the consumers and want to customize the error response as per the need.
I was checking JSONThreatProtection policy. my policy code is as follows:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JTP">
<DisplayName>JTP</DisplayName>
<Properties/>
<ArrayElementCount>2</ArrayElementCount>
<ContainerDepth>3</ContainerDepth>
<ObjectEntryCount>4</ObjectEntryCount>
<ObjectEntryNameLength>10</ObjectEntryNameLength>
<Source>request</Source>
<StringValueLength>20</StringValueLength>
</JSONThreatProtection>
Now if I send a request as follows:
{
"myproper1":"sdlfks",
"myproper2":"myvalue",
"myproper3":"myvalue",
"myproper4":"myvalue",
"myproper5":"myvalue"
}
I was expecting fault “ExceededObjectEntryCount” in the response (as per the policy documentation) but the fault generated is “ExecutionFailed”. Please correct me if I am wrong.
Now the problem is if want to customize the error messages based on the fault name I cannot do that because in any case same fault is written (be it be ObjectEntryCount or ObjectEntryNameLength or any other cause).
Another problem is if I want to extract part of the error message then its difficult to identify which variable will hold the error message, is it error.message/ fault.string because this behavior is not consistent across all the policies which make is very difficult to create a generic error handling pattern for policy faults.
This information is not very clear in the documentation. There are many other observations regarding faults and fault name which I have mentioned in other posts as well. I personally feel that the errors/error codes needs improvement in APIGEE. It is one of the very important aspect in API program.