What HTTP status code do you use when endpoint is disabled by feature-flag / feature-toggle?
Asked Answered
S

1

8

I have been using 503 Service Unavailable or down for maintenance.

However some http client libraries i.e. axios treat 503 as retriable error.

It makes sense to retry it if the response is produced due to high load but 503 also fits the feature-toggle case.

Any suggestion on other codes people use ?

Sentient answered 18/2, 2020 at 15:28 Comment(2)
What would the behavior be if the feature were never implemented? (E.g. running against a older version of the server.) That's what you should do if the feature flag is disabled.Venial
The toggle is to allow transitioning from one implementation to another, there will be period of gradual transition. Bombing out with an error will raise unnecessary warnings.Sentient
R
7

Status codes are meta data that belong to the "transferring documents over a network" domain. Shared semantics of the status codes is what allows general-purpose HTTP aware components to act intelligently.

So what you should be doing is thinking about the HTTP semantics.

For example, if your server doesn't have access to a current representation of the resource identified by the target-uri of the request, then you should be issuing a 404 Not Found response. If the request is forbidden, then 403 Forbidden. Or 451 Unavailable for Legal Reasons when that is the intended meaning.

In other words: it depends.

But what it doesn't depend on is "feature flag"; that's an implementation detail. The "uniform interface" is a facade that hides those sorts of technical details that vary from one implementation to another. From the outside, your API provides the illusion that your machine is just another boring web server.

Reconnoitre answered 18/2, 2020 at 21:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.