Skip to content

Fail on purpose

POST
/billing/admin/failure-test
curl --request POST \
--url https://api.sloose.com/billing/admin/failure-test \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "kind": "a" }'

Operator route: the shared ADMIN_TOKEN alone, never a person’s session, staff included. Throws an error no route handles, to prove that a deployment’s failures reach a person: the API logs [api] unhandled FailureTest (or FailureTestB, FailureTestC), answers 500, and mails staff, and Cloudflare’s Workers Observability records the failure as an issue, which is what the account’s failure alert is fed by. The body is optional: {"kind": "a" | "b" | "c"} from a closed list (default a), never a caller’s text; each kind is a different error name and so, to Cloudflare, a different issue. It writes one row: the claim that the day’s staff mail for this error’s name is spent. What the 500 does not say: the staff mail is sent after the answer and at most once in the 24 hours from the first call of a kind on an environment — whether or not that mail reached anybody — so a second call of a kind inside them proves Cloudflare’s half only and no mail arrives; and a kind whose issue exists opens no new issue, resolved or not; Cloudflare mails through an issue automation (a new issue at threshold 1, a count crossing, or a return after a quiet period), never through the notification policy alone. Each kind is spent once it has made its issue, and all three are on staging (a also on production). A body is now read, where the route once ignored any: no body and {} still throw FailureTest as before (and a ?kind= in the query is ignored); {"kind": null} is a kind that is not on the list and is 400; a JSON body that is junk or empty under a JSON content type is 400, and a body of any other content type (text/plain, a form, none declared) is 415.

Media typeapplication/json
object
kind

a (default): FailureTest. b: FailureTestB. c: FailureTestC. Each has a name and a message of its own and opens its own issue the first time on an environment; all three are spent on staging and a on production, so a request of a spent kind opens no new issue.

string
Allowed values: a b c

A body that is not JSON of this shape, or a kind that is not a, b or c (code: INVALID_BODY): nothing is thrown, nothing is claimed and nobody is mailed.

Media typeapplication/json

The error envelope every non-2xx answer uses.

object
error
required

Human-readable explanation.

string
code

Machine-readable reason. Absent on a few legacy 400s.

string
key
additional properties
Examplegenerated
{
"error": "example",
"code": "example"
}

A bearer that is neither the token nor a live session (code: AUTH_REQUIRED).

Media typeapplication/json

The error envelope every non-2xx answer uses.

object
error
required

Human-readable explanation.

string
code

Machine-readable reason. Absent on a few legacy 400s.

string
key
additional properties
Examplegenerated
{
"error": "example",
"code": "example"
}

Not the ADMIN_TOKEN (code: ADMIN_REQUIRED): no bearer, a customer’s session, an API token, or a staff member’s session, which opens the rest of the backoffice and not this. A staff session that has passed no second factor recently is refused before that, as on every backoffice route (code: SECOND_FACTOR_REQUIRED).

Media typeapplication/json

The error envelope every non-2xx answer uses.

object
error
required

Human-readable explanation.

string
code

Machine-readable reason. Absent on a few legacy 400s.

string
key
additional properties
Examplegenerated
{
"error": "example",
"code": "example"
}

A body that is not JSON (text/plain, a form, or no content type declared): nothing is thrown, claimed or mailed. A request with no body at all is not one.

Media typeapplication/json

The error envelope every non-2xx answer uses.

object
error
required

Human-readable explanation.

string
code

Machine-readable reason. Absent on a few legacy 400s.

string
key
additional properties
Examplegenerated
{
"error": "example",
"code": "example"
}

Always, for the ADMIN_TOKEN and a kind from the list: the failure asked for, answered as every unhandled error is.

Media typeapplication/json
object
error
required
string
Allowed values: internal error
Example
{
"error": "internal error"
}

The restore switch is on (code: MAINTENANCE): every route but /health and /robots.txt is refused before anything is read, except the operator’s own POST /staff/people/{id}/delete with the ADMIN_TOKEN. Sloose is down for maintenance. Please try again in a few minutes.

Media typeapplication/json
object
error
required
string
code
required
string
Allowed value: MAINTENANCE
Example
{
"code": "MAINTENANCE"
}
Retry-After
integer

Seconds until asking again is worth it (300 while the switch is on).

Report a problem with this page

sloose.com