Errors and status codes

One shape for every failure. The HTTP status is the category; the code is the exact reason.

{
  "success": false,
  "source": "anilist",
  "version": "v1",
  "endpoint": "anime",
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Path parameter \"id\" must be a number",
    "hint": "Numeric ids only, up to 10 digits."
  },
  "meta": { "cached": false, "tookMs": 3, "generatedAt": "...", "requestId": "..." }
}

Every code

CodeHTTPWhen it happens
BAD_REQUEST400The request could not be parsed at all.
VALIDATION_ERROR422A required parameter is missing, a number is not a number, or a value is too long.
UNAUTHORIZED401A key is required but absent, or the key is not valid.
FORBIDDEN403The caller may not do this, for example an admin route without a session.
NOT_FOUND404No scraper at that slug and version, or no endpoint at that path.
METHOD_NOT_ALLOWED405Only GET and OPTIONS are served.
SCRAPER_DISABLED403The scraper is registered but switched off.
RATE_LIMITED429The per minute window for this caller is spent.
SOURCE_ERROR502The upstream site answered with an error, or refused the request.
SOURCE_TIMEOUT504The upstream did not answer inside the request budget.
SCRAPER_ERROR500The scraper handler threw, usually a selector that no longer matches.
INTERNAL500The platform itself failed before or after the scraper ran.

What to do with them

  • VALIDATION_ERROR is yours: fix the parameter. Retrying changes nothing.
  • SOURCE_ERROR and SOURCE_TIMEOUT are upstream. One retry with backoff is reasonable, a loop is not.
  • SCRAPER_ERROR means the scraper is broken against its source. It is reported on the admin dashboard with the message that was thrown.
  • RATE_LIMITED carries the reset time. Sleep until then instead of hammering.