Skip to content

Commit

Permalink
CCM6126: initial commit for 413 error
Browse files Browse the repository at this point in the history
  • Loading branch information
smaldon-bjss committed Sep 27, 2024
1 parent fc8c508 commit 664febe
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
8 changes: 7 additions & 1 deletion proxies/shared/partials/Partial.Target.FaultRules.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<FaultRule name="combined_backend_fault_handler">
hared/partials/Partial.Target.FaultRules.xml:FaultRule name="combined_backend_fault_handler">
[% include './partials/Partial.Component.SetResponseDefaults.xml' %]
<Step>
<Name>ExtractVariables.ErrorMessage</Name>
Expand Down Expand Up @@ -72,6 +72,12 @@
<Name>RaiseFault.404NotFound</Name>
<Condition>response.status.code = 404</Condition>
</Step>
<Step>
<Name>RaiseFault.413RequestTooLarge</Name>
<Condition>
response.status.code = 413 and response.content Like "*Request Too Long*"
</Condition>
</Step>
<Step>
<Name>RaiseFault.400BackendException.OdsCodeRequired</Name>
<Condition>response.status.code = 400 and response.content Like "*odsCode must be provided*"</Condition>
Expand Down
45 changes: 45 additions & 0 deletions proxies/shared/policies/RaiseFault.413RequestTooLarge.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
This policy raises a 406 error response for a missing or invalid Accept header.
Valid values are:
* `*/*`
* `application/json`
* `application/vnd.api+json`
Raisefault policies stop the execution of the current flow and move to the error flow, which returns the error response defined here to the requesting application.
For more information on RaiseFault policies within Apigee see the following resource:
* https://docs.apigee.com/api-platform/reference/policies/raise-fault-policy
-->
<RaiseFault async="false" continueOnError="false" enabled="true" name="RaiseFault.413RequestTooLarge">
<DisplayName>RaiseFault.413RequestTooLarge</DisplayName>
<Properties/>
<FaultResponse>
<Set>
<Headers/>
<StatusCode>413</StatusCode>
<ReasonPhrase>Request message was larger than the service limit</ReasonPhrase>
<Payload variablePrefix="@" variableSuffix="#">
{
"errors" : [
{
"id" : "@messageid#.0",
"code" : "CM_TOO_LARGE",
"links" : {
"about" : "{{ ERROR_ABOUT_LINK }}"
},
"status" : "413",
"title" : "Request too large",
"detail" : "Request message was larger than the service limit",
"source" : {
"header" : "Accept"
}
}
]
}
</Payload>
</Set>
</FaultResponse>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</RaiseFault>

0 comments on commit 664febe

Please sign in to comment.