-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make ReturnOverrides more flexible when returning errors #2693
Labels
Comments
What about also letting us choose the return Code? |
It is already possible and part of |
matiasinsaurralde
added a commit
to matiasinsaurralde/tyk
that referenced
this issue
Dec 11, 2019
matiasinsaurralde
added a commit
to matiasinsaurralde/tyk
that referenced
this issue
Dec 11, 2019
Merged
matiasinsaurralde
added a commit
to matiasinsaurralde/tyk
that referenced
this issue
Dec 11, 2019
buger
pushed a commit
that referenced
this issue
Dec 23, 2019
Fixed by #2731 |
matiasinsaurralde
added a commit
to matiasinsaurralde/tyk
that referenced
this issue
Jan 7, 2020
matiasinsaurralde
added a commit
to matiasinsaurralde/tyk
that referenced
this issue
Jan 7, 2020
buger
added a commit
that referenced
this issue
Jan 21, 2020
The previous PR #2731 contained an error, and always forced return custom error: which brakes backward compatibility. In this PR I added tests covering all return overrides functionality and normalized its behavior for JSVM and Python. Additionally, it use reverse logic now, and plugin needs set `ReturnOverrides.OverrideError` (JS) or `return_overrides.override_error` (Python) to `true` in order to override the body of response. Additionally, I renamed `response_error` field to `response_body`, because it makes way more sense. The old field still can be set for backward compatibility. #2693
I added one more fix to this, details inside this PR #2815 |
buger
added a commit
that referenced
this issue
Jan 21, 2020
The previous PR #2731 contained an error, and always forced return custom error: which brakes backward compatibility. In this PR I added tests covering all return overrides functionality and normalized its behavior for JSVM and Python. Additionally, it use reverse logic now, and plugin needs set `ReturnOverrides.OverrideError` (JS) or `return_overrides.override_error` (Python) to `true` in order to override the body of response. Additionally, I renamed `response_error` field to `response_body`, because it makes way more sense. The old field still can be set for backward compatibility. #2693
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
Currently when using rich plugins, it's possible to override the response by using
ReturnOverrides
, this structure takes two parameters: HTTP status code and body.When the HTTP status code is higher than 400 and a body like "test" is used, the generated response body looks like this:
{"error": "test"}
.It would be more flexible if we can allow the user to fully customize this behavior in error scenarios. We could keep the current functionality by default (and for compatibility purposes) and introduce a flag like
disable_json_error
or a similar name.When this flag is set to true, with the same parameters specified in 2) we would get response body like "test".
This could be useful for cases where it's required to fully customize the error output.
When using status codes lower than 400 we don't really add any JSON wrapper, so the user already has full flexibility in this case.
Describe the solution you'd like
The easiest solution would be to add a flag to the
ReturnOverrides
data structure. This will help us with compatibility too.The text was updated successfully, but these errors were encountered: