cancel
Showing results for 
Search instead for 
Did you mean: 

Binary output - error pipeline - custom http codes

Szymon
New Contributor II

There is a requirement for the following:
Error pipeline for an ultra pipeline which responses with custom HTTP code, e.g. 500.
Why:
…The third party API caller shall receive a proper HTTP code, not only HTTP 200 with error message.
…Or when the pipeline goes into an error it will receive 504 gateway timeout, just because, on standard snaplogic i unable to catch the errors.

So:
…I have implemented the ultra pipeline(A) and implemented error pipeline(B).
…In the ultra(A) i have configured the error pipeline(B), so all the snaps use that error pipeline.
…In the error pipeline(B), depending on the error, i have implemented custom error codes using Mapper Snap (Document → Binary), see pic below.

image

BUT, when I save the pipeline(A) and the engine tries to initialize the ultra pipeline, i get the message from the engine:

Error pipeline does not meet the requirements
Reason: An unlinked output must be available when an error pipeline is used with an Ultra pipeline
Resolution: Please redesign the error pipeline to have a single unlinked document output view

  1. is it not possible to have a binary output in ultra error pipeline(B)? YES or NO
  2. what is the alternative to output custom error codes from error pipeline(B), so the calling party sees, not HTTP 200, but HTTP 500? I DO NOT WANT to use Error View at the particular snaps in Ultra pipeline(A)!

Any ideas?

1 ACCEPTED SOLUTION

Hi @Szymon,

I created a sample ultra pipeline with an error pipeline and you actually can’t have an open binary output view on the error pipeline, it has to be document output view. However, you can still manipulate the status code for the error message.
This is a simple error pipeline that outputs the error message if there are any errors from the main pipeline.
image
image

If you call this API and if the pipeline has an error, for example you’ll receive the following response based on the configuration of the mapper snap in the error pipeline:

image
You can notice that the status in the response corresponds to the status in the Mapper snap.

View solution in original post

6 REPLIES 6

j_angelevski
Contributor III

Hi @Szymon,

  1. is it not possible to have a binary output in ultra? YES or NO

Yes, the ultra pipeline should have at least one open output view and one input view. If you use an error pipeline with the ultra pipeline, the error pipeline must have an open output view.

  1. what is the alternative to output custom error codes from error pipeline, so the calling party sees, not HTTP 200, but HTTP 500? I DO NOT WANT to use Error View at the particular snaps in Ultra pipeline!

To output a custom status code, you can pass the $status header to the output snap ( for example JSON Formatter in the Binary header properties ) with your desired value. You can also do the same in a Mapper snap with binary output view if you want custom status code.
image

Szymon
New Contributor II

Thank you,
I am sorry, I was not making it 2000% clear, so updated the initial post for that.

ad 1. Now, the error, that I get is referring to the error pipline, that is used in ultra.
So, is it not possible to use binary output view in the error pipeline?

ad2. The goal is not to output custom http codes from the ultra pipeline itself, BUT from the error pipeline. When in error pipeline I do - as you suggest - convert document to binary using $status and $content, the error mentioned occurs, as soon as engine initializes the ultra pipeline.

Yes it is possible, however, if you are trying that with the Document to Binary snap make sure the data on the input has the $content field otherwise that snap will fail because it requires the content field. You can also output custom message from the error pipeline, you can do something like this:

  1. Drop a Mapper snap
  2. Change the output view to binary type in the Views tab
  3. Write the below expression ( this is only a sample, it doesn’t have to be like this )
    image
    If there is an error in your pipeline, the error pipeline will output this error message if configured properly.

Szymon
New Contributor II

Thanks again.
However, the answer does not refer to the question.
I have edited the initial post again with more information.