{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • Edge/API Management /
avatar image
0
Question by Soma Ghosh · Jan 17, 2020 at 04:10 PM · 324 Views api proxyedgeerrorerror handlingapigee cloud413request entity too large

How to capture 413 error in Apigee?

Can you please suggest to me how I can capture a 413 error in Apigee? I added the below conditions in proxy <faultRule>. Tried all 3 conditions, none of them worked.

error.errorcode = "protocol.http.TooBigBody"

error.state.code = 413

error.class="com.apigee.errors.http.user.requestTooLarge"

<FaultRule name="Too Large Request">

<Condition>(error.errorcode = "protocol.http.TooBigBody")</Condition>

<Step>

<Name>RF-TooLargeRequest</Name>

</Step>

</FaultRule>

Tried the same condition in <DefaultFaultRules>, it still didn't work. Appreciate your suggestion.

Comment
Add comment
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Close

4 Answers

  • Sort: 
avatar image
0

Answer by Sujnana Rai · Jan 17, 2020 at 05:15 PM

Try this - error.status.code=413.

Comment
Add comment Show 3 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Soma Ghosh · Jan 17, 2020 at 05:36 PM 0
Link

I tried that. It did not work.

avatar image Sujnana Rai Soma Ghosh · Jan 17, 2020 at 06:13 PM 0
Link

I assumed the 413 error is from backend service. Looks like the 413 error happening in proxy.

Check the value of the flow variable fault.name in trace & add condition like below.

<Condition>(fault.name Matches "<value of fault.name>")</Condition>
avatar image Soma Ghosh · Jan 17, 2020 at 07:40 PM 0
Link

it is happening in proxy, not even going to backend. I am not sure about the fault.name for this error, not able to find this in trace.

avatar image
0

Answer by Jayesh Upadhyay · Jan 21, 2020 at 09:09 AM

Hi @Soma Ghosh


In your proxy can you add javascript policy under FaultRules section. In that Javascript code can you add following lines.

print("Faultname " + context.getVariable('fault.name'));

print("Error Status Code " + context.getVariable('error.status.code'));

print("Error State " + context.getVariable('error.state'));

Start Tracing the proxy and make the call. If error is coming from proxy you will see values being populated for above flow variables.

Try and reproduce the error and see what's printed on you trace output from all transaction window.

Comment
Add comment Show 1 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Soma Ghosh · Jan 23, 2020 at 09:53 PM 0
Link

Within FaultRules I am not able to print the 413 error status code.

I created a separate test proxy and added DefaultFaultRules with <AlwaysEnforce> as 'true'.

In DefaultFaultRules I am able to print fault.name='TooBigBody' and error.status.code=413.

Any idea why I am not able to capture the error in FaultRules?

avatar image
0

Answer by Jayesh Upadhyay · Jan 24, 2020 at 08:52 AM

@Soma Ghosh

According to the documentation: A DefaultFaultRule acts an exception handler for any error that is not explicitly handled by FaultRule.

https://docs.apigee.com/api-platform/fundamentals/fault-handling#creatingfaultrules-creatingadefaultfaultrule

If you are interested in this topic

Couple of Apigee community page link explaining error handling in quite detail.

https://community.apigee.com/articles/23724/an-error-handling-pattern-for-apigee-proxies.html

https://community.apigee.com/articles/47312/an-improved-pattern-for-fault-handling.html

Also link to 4MV4D by @Anil Sagar @ Google explains basics of Default Fault rule.

In Summary for your above example to capture 413 you need to use DefaultFaultRule as you tried out in test proxy.

Comment
Add comment · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Peter Douglas · Jun 16, 2020 at 01:34 PM

We are facing this 413 issue with a scenario involving sending a large file (> 10MB, very edge case). It blows up the message processor and no policies or fault rules in the proxy are hit or show up in the trace. In fact, even though the trace correctly shows the error:

{"fault":{"faultstring":"Body buffer overflow","detail":{"errorcode":"protocol.http.TooBigBody"}}}

The end result on the client is 502 Bad Gateway.

Even though the trace shows an event "Proxy Post Client Flow Started," again, no postflow faults or policies are traced. The workaround we are considering is turning streaming on and checking the file size, but it seems a pity for such an edge case. 99.9% of requests will not be anywhere close to that file size.

Comment
Add comment Show 7 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Peter Douglas · Jun 16, 2020 at 02:04 PM 0
Link

Testing with a POC proxy that raises a fault and does nothing else it works with an appropriate sized request; when I try a large request the proxy doesn't run the policy and returns a 502.

@Soma Ghosh, Jayesh Upadhyay did you find a solution for handling this?

avatar image Dino-at-Google ♦♦ Peter Douglas   · Jun 16, 2020 at 02:49 PM 1
Link

This seems like a thing you should contact Apigee support about.

avatar image Peter Douglas Dino-at-Google ♦♦ · Jun 16, 2020 at 04:12 PM 0
Link

Sweet Dino, as ever we appreciate your insight!

avatar image Soma Ghosh · Jun 16, 2020 at 04:47 PM 1
Link

Hi @Peter Douglas,

I added DefaultFaultRule in my proxy default.xml with the step to handle error in case of a large file size. Also added AlwaysEnforce= true. So my DefaultFaultRule looks like below.

As the documentation says, DefaultFaultRule acts as an exception handler of any error that is not explicitly handled by FaultRules conditions.

<DefaultFaultRule name="DefaultFaultRule">
<Step> <Condition>(fault.name = "TooBigBody")</Condition> <Name>AM-LargePayloadError</Name> </Step>
<AlwaysEnforce>true</AlwaysEnforce>
</DefaultFaultRule>

avatar image Peter Douglas Soma Ghosh · Jun 16, 2020 at 05:14 PM 0
Link

That worked, Soma! Thanks for everyone's attention and quick response! Verified solution.

avatar image Peter Douglas Soma Ghosh · Jun 16, 2020 at 05:41 PM 0
Link

Update: we have this working perfectly with requests that are marginally over the limit, eg., 10.1 MB. One test scenario includes uploading an extremely large file (20 MB) which persists in returning a 502 to the client in spite of the trace showing a 413. Streaming has been ruled out, we want to cap the file upload at 10 MB. We will release this as is - users are clearly instructed on max file size. We will still open a ticket with Apigee on the extremely large file returning 502 issue.

avatar image Elzo Pauw Peter Douglas · 5 days ago 0
Link

Our team seems to have found the solution. The error orignated in the proxyEndPoint and the default fault rule should be located here to catch the error. When inside the targetEndPoint flow the rule gets skipped. We caught it by putting a raisefault policy in the defaultfaultrule looking for error.code === 413.

Hope this solves your problem as well

Follow this Question

Answers Answers and Comments

102 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to customize Edge's default 400 error message? 1 Answer

close_notify error 0 Answers

i just created a new proxy, while deploying to Edge seeing this error. 1 Answer

Generate HTTP methods automatically when creating an API Proxy 1 Answer

Which sequence is best for Spike Arrest policy ? 1 Answer

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges