You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// if it cannot parse the response fallback to the textual content of the body
211
+
212
+
if (false === $endpointOptions[RestConfigurableProtocol::OPTION_RESPONSE_FALLBACK_ON_ERROR]) {
213
+
throw$e;
214
+
}
215
+
216
+
trigger_error('Falling back to the original response payload when the deserialization fails and a custom response format isn\'t defined will throw an exception in v3.', E_USER_DEPRECATED);
# 2. Deprecate the response fallback on the RestConfigurableProducer class
2
+
3
+
Date: 2020-05-08
4
+
5
+
## Status
6
+
7
+
Accepted
8
+
9
+
## Context
10
+
11
+
Currently the RestConfigurableProducer will pass the payload received from the target system to the serializer. If this one fails, it will catch the exception, fallback to the original response, **and continue the execution**.
12
+
13
+
This was done to allow certain APIs to return a non-deserializable response while still being able to continue the execution, either **by ignoring the payload** (i.e.: when the response code is enough) or to evaluate it to something else.
14
+
15
+
This makes the evaluator vulnerable, as it has no guarantee that what it will expect is something **that can be evaluated**.
16
+
17
+
Due to the fallback is present by default, one endpoint **could randomly fail** if the target system decides to send back a response in a format that is not expected by the application.
18
+
19
+
## Decision
20
+
21
+
We decided to deprecate the response fallback in this version and remove it **in the next major version**.
22
+
23
+
A new parameter was introduced in the `RestConfigurableProducer` (`response_format`) that will define the expected response format, and this format is passed to the deserialize function to instantiate the appropriate visitor. For example, a PlainTextVisitor could be implemented to process non-JSON responses while still producing **a evaluable object**. By default, if `response_format` is not setup, `encoding` will be passed.
24
+
25
+
## Consequences
26
+
27
+
In order to introduce this change in a backwards compatible way, a new boolean option was introduced in the `RestConfigurableProtocol` (`response_fallback`) that will prevent the fallback. Setting it to `false`**will throw an exception** when the payload cannot be deserialized.
0 commit comments