I have a server, which does a request to AWS S3.
What is the correct status code, if my server's request to S3 failed?
Let me break it down more.
I googled and found that 502 Bad Gateway, might be correct here, but I'm not sure because it also talks about my server being a proxy, which it isn't. My server does additional processing and database calls with the content of the request before the call to AWS S3, as well as after it got the result from AWS.
This is from my experience:
Let's consider your scenario:
Considering your ServiceA actually does some business logic instead of simply calling ServiceB (like a proxy), I think it is better to response with 200 OK
to the client and wrap the actual results of calling ServiceB to response payload.
For example, like this:
{
"serviceBresponse": {
"status": 503,
... another information
}
}
Semantically it means the following:
Is your ServiceA respondable? Yes, it is. Is your ServiceA was able to process the client request? Yes, it was. What ServiceB responded? See the payload.
Since with this approach you can difer from client perspective which service is actually responded with non-200 status. If ServiceA responded with non-200 status, then the ServiceA was not able to process the request. If ServiceA responded with 200, then you can be sure that ServiceA is okay.