Muthugomu

Strange behavior in API Gateway when response message size exceeds the limit

Blog Post created by Muthugomu Employee on Mar 9, 2018

I have noticed a strange behavior in API Gateway all versions (validated on 8.x and 9.3CR01) when the following conditions are met:

  1. Response message size from the end point exceeds the response message size limit indicated in the Routing assertion and if the Routing assertion is marked to Never fail as long as target returns an answer.
  2. If Add Audit Details assertion is added immediately following Routing Assertion and it contains ${response.mainpart} variable to print the response.

 

Gateway processes the service perfectly fine from the audit log, however an error will be reported to the end user who calls the service, which is contracting.  I expected Gateway to show the same error in the audit log as well, so the developer won't go crazy.

 

 

Here's the steps to reproduce the issue:

 

  1. Published a Sample Service to return an XML Message as shown:Sample Service
  2. Published another service to call the above service (calling it as Response Limit) followed by an Add Audit Detail assertion as shown, notice that it uses the default Restrict Message size and Assertion outcome is set to Never fail as long as target returns an answer

      

Routing Properties showing the default values for size

 

Now executing the above service works fine as shown:

         Service Invoked and it returns positive response

Modify the Routing Assertion by checking "Override maximum message size" and change the message size to 50 (the service actually returns 54 bytes) as shown:

      Routing Limit

 

Audit Details with response.mainpart

 

      Now executing the service throws Internal Server Error as shown:       

 

      Internal Error

 However when looked at the audit log, the service got executed perfectly fine as shown, which is strange as it is presenting different views.  End User getting error, but audit log shows it worked fine which is misleading.  Further debugging, I found that this issue caused by Audit Detail assertion having ${response.mainpart}, if I just include ${response.http.status} then it works fine. I disabled the Audit Detail assertion and tried, it worked fine.

 

   

 

         Audit Log

 

Then again, I removed ${response.mainpart} from audit details assertion and tried, it worked as well.  It looks like ${response.mainpart} in audit details caused the issue.  This results in inconsistent behavior (Log shows the service is successful, however the user sees an error)

 

 

Now it works fine:

 

Service Invoked and it returns positive response

 

Question:

1. I was expecting Routing Assertion to fail as it is returning 54 bytes, though we have a limit set to 50 bytes?  Why Routing assertion did not fail?

2. Why having response.mainpart in audit cause this strange error?

 

 

Appreciate if someone can answer the above questions.

Outcomes