Skip to content

Commit 627cb15

Browse files
committed
Update Fault rules to use status codes
1 parent 2476407 commit 627cb15

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<!--
3+
This policy raises a 400 error response for an application failure.
4+
5+
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.
6+
7+
For more information on RaiseFault policies within Apigee see the following resource:
8+
* https://docs.apigee.com/api-platform/reference/policies/raise-fault-policy
9+
-->
10+
<RaiseFault async="false" continueOnError="false" enabled="true" name="RaiseFault.400BadRequest">
11+
<DisplayName>RaiseFault.400BadRequest</DisplayName>
12+
<Properties/>
13+
<FaultResponse>
14+
<Set>
15+
<Headers>
16+
<Header name="Content-Type">application/fhir+json</Header>
17+
</Headers>
18+
<StatusCode>400</StatusCode>
19+
<ReasonPhrase>BadRequest</ReasonPhrase>
20+
</Set>
21+
</FaultResponse>
22+
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
23+
</RaiseFault>

proxies/live/apiproxy/targets/target.xml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,29 @@
2727
</Response>
2828
</PostFlow>
2929
<FaultRules>
30-
<FaultRule name="404_Not_Found">
30+
<FaultRule name="400_Bad_Request">
3131
<Step>
32-
<Name>RaiseFault.404NotFound</Name>
32+
<Name>RaiseFault.400BadRequest</Name>
3333
</Step>
34-
<Condition>response.header.x-amzn-ErrorType = "IncompleteSignatureException"</Condition>
34+
<Condition>response.status.code = 400</Condition>
3535
</FaultRule>
36-
<FaultRule name="unauthorized">
36+
<FaultRule name="Unauthorized">
3737
<Step>
3838
<Name>RaiseFault.401Unauthorized</Name>
3939
</Step>
4040
<Condition>oauthV2.OauthV2.VerifyAccessToken.failed = true or fault.name = "invalid_access_token" or fault.name = "InvalidAccessToken" or fault.name = "access_token_not_approved" or fault.name = "apiresource_doesnot_exist" or fault.name = "InvalidAPICallAsNo" or fault.name = "ApiProductMatchFound" or fault.name = "access_token_expired"</Condition>
4141
</FaultRule>
42-
<FaultRule name="internal_server_error">
42+
<FaultRule name="404_Not_Found">
43+
<Step>
44+
<Name>RaiseFault.404NotFound</Name>
45+
</Step>
46+
<Condition>response.header.x-amzn-ErrorType = "IncompleteSignatureException"</Condition>
47+
</FaultRule>
48+
<FaultRule name="500_Internal_Server_Error">
4349
<Step>
4450
<Name>RaiseFault.500InternalServerError</Name>
4551
</Step>
46-
<Condition>response.status_code = "400"</Condition>
52+
<Condition>response.status.code = 500</Condition>
4753
</FaultRule>
4854
</FaultRules>
4955
<HTTPTargetConnection>

0 commit comments

Comments
 (0)