Want to remove default Javascript Error response content

Not applicable

Hi, Currently i am getting below response if any javaScript Error occured in my proxy. I want to remove/Customize this response message.

{"fault":{"faultstring":"Execution of target-ca-response failed with error: Javascript runtime error: \"ReferenceError: \"logger\" is not defined. (target_ca_response_js#47). at line 47 \"","detail":{"errorcode":"steps.javascript.ScriptExecutionFailed"}}}

No policy seems working after getting this error. i also tried to put my policy under <FaultRules> tag. but that also didn't work for me.

Suggest me a solution.

Details:

Applied in proxy end point:

<FaultRules>
        <FaultRule name="invalid_key_rule">
            <Step>
                <Name>Error500</Name>
                <Condition>(message.status.code = 500)</Condition>
            </Step>
        </FaultRule>
    </FaultRules>

Error500 railsefault policy

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RaiseFault async="false" continueOnError="false" enabled="true" name="Error500">
    <DisplayName>Error500</DisplayName>
    <FaultRules/>
    <Properties/>
    <FaultResponse>
        <Set>
            <StatusCode>500</StatusCode>
            <ReasonPhrase>Server Error</ReasonPhrase>
           <Payload contentType="text/plain">Error Occured</Payload>
        </Set>
      <Remove>
       {message.content}
       {error.content}
        {error}
        <Payload contentType="application/json">{request.content}</Payload>
        <Payload contentType="application/json"></Payload>
        <Payload contentType="application/json">{message.content}</Payload>
        <Payload contentType="application/json">{error.content}</Payload>
      </Remove>
    </FaultResponse>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</RaiseFault>
0 5 677
5 REPLIES 5

Abhishek_Subram
Participant V

Hi @Vinay Soni,

This is a hard error & must be handled within a Fault Rule. Are you able to see the Raise Fault being executed in the trace? If not there is something wrong in your proxy configuration. Please create a simple proxy & try adding the Fault Rule.

The script execution errors are set in the fault.name variable. You can optionally add the below condition to identify in your Raise Fault policy.

<Condition>
	(fault.name="ScriptEvaluationFailed" OR fault.name="ScriptExecutionFailed")
</Condition>

Thanks,

Abhishek

2 4 0

@Abhishek Subramanyai have already tried to add this condition but the fault rule is not picking up in case of default error. i am also adding the trace snapshot.

Can you give a sample proxy to do thiscapture.png

0 3 0

Abhishek_Subram

Hi @Vinay Soni,

I have created a sample proxy to address your issue -

Snapshot -

1775-capture-js-error.jpg

Proxy -js-error-rev1-2016-01-11.zip

Thanks,

Abhishek

0 2 0

Hi @Abhishek Subramanya

I did in a little modification in your proxy and added the javascript at target end point. now the same fault rule stopped working but it's working if we put the faultRule in target end point.

Why it's not working in proxy end point

1776-js-error-rev1-2016-01-11-rev1-2016-01-11.zip

0 1 0

Abhishek_Subram

Hi @Vinay Soni,

The behavior of the Fault Rule is dependent on the place you add it. Please find the rules below -

Request Path:

  1. Fault in ProxyRequest: fault rules defined at ProxyEndpoint execute
  2. Fault in Routing: fault rule defined at ProxyEndpoint execute
  3. Fault in TargetRequest: fault rules defined at TargetEndpoint execute
  4. Fault in outbound request to target URL: fault rules defined at TargetEndpoint execute

Response Path:

  1. Fault in TargetResponse: fault rules defined at TargetEndpoint execute
  2. Fault in ProxyResponse: fault rules defined at ProxyEndpoint execute
  3. Fault in returning response to ProxyEndpoint: fault rules defined at ProxyEndpoint execute

For more information on Fault handling, please refer to Apigee documentation.

Thanks,

Abhishek

0 0 0
Top Labels in this Space
Top Solution Authors