-
Notifications
You must be signed in to change notification settings - Fork 49
Use redirect property on HTTP and OpenAPI calls #1013
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
base: main
Are you sure you want to change the base?
Conversation
...ttp/src/main/java/io/serverlessworkflow/impl/executors/http/AbstractHttpExecutorBuilder.java
Show resolved
Hide resolved
Signed-off-by: Matheus Cruz <matheuscruz.dev@gmail.com>
Signed-off-by: Matheus Cruz <matheuscruz.dev@gmail.com>
| WorkflowError.communication( | ||
| response.getStatus(), | ||
| t, | ||
| new RedirectValidationException( | ||
| String.format( | ||
| "The property 'redirect' is %s but received status %d (%s); expected status in the %s range", | ||
| redirect, | ||
| response.getStatus(), | ||
| response.getStatusInfo().getReasonPhrase(), | ||
| expectedRange))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| WorkflowError.communication( | |
| response.getStatus(), | |
| t, | |
| new RedirectValidationException( | |
| String.format( | |
| "The property 'redirect' is %s but received status %d (%s); expected status in the %s range", | |
| redirect, | |
| response.getStatus(), | |
| response.getStatusInfo().getReasonPhrase(), | |
| expectedRange))) | |
| WorkflowError.communication( | |
| response.getStatus(), | |
| t, | |
| String.format( | |
| "The property 'redirect' is %s but received status %d (%s); expected status in the %s range", | |
| redirect, | |
| response.getStatus(), | |
| response.getStatusInfo().getReasonPhrase(), | |
| expectedRange)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think there is need to create a new exception, just the formated message within the error should suffice
| boolean isSuccess = statusFamily.equals(Response.Status.Family.SUCCESSFUL); | ||
| boolean isRedirect = statusFamily.equals(Response.Status.Family.REDIRECTION); | ||
|
|
||
| boolean valid = redirect ? (isSuccess || isRedirect) : isSuccess; | ||
| if (!valid) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets use import static for Response.Status.Family values
| boolean isSuccess = statusFamily.equals(Response.Status.Family.SUCCESSFUL); | |
| boolean isRedirect = statusFamily.equals(Response.Status.Family.REDIRECTION); | |
| boolean valid = redirect ? (isSuccess || isRedirect) : isSuccess; | |
| if (!valid) { | |
| if (statusFamily != SUCCESSFUL || redirect && statusFamily != REDIRECTION) { |
Changes
RuntimeExceptionthe theserverlessworkflow-impl-httpmodule calledRedirectValidationException.AbstractHttpExecutorBuilderresponsible for applying redirect validation rules for the HTTP response. When the validation fails, it pass the response status code to theWorkflowErrorinstance.TODO
redirectbehavior (when the upstream server returns a 3XX status code)Closes #959