SpaceTradersAPI / api-docs

The API documentation for the SpaceTraders API
143 stars 36 forks source link

[Feature Request ✨] Error message noting outdated token #37

Closed jonchurch closed 1 year ago

jonchurch commented 1 year ago

tldr; reset is a feature not an HTTP error, should be treated like one

In requests that contain a Token, but are for invalid game versions, return a friendly error message letting users know their token is not valid post reset.

This would require encoding which version a token was generated for, and checking it against the current version of the game.

I think this would go a long way towards communicating the concept, and occurrence, of resets to players in a clear way. If it is it's own error code, then we can programmatically check too.

Current error message is:

{
  "error": {
    "message": "Token was invalid or could not be parsed: \"eyJhbGciOi...\"",
    "code": 4104
  }
}

I'm suggesting something like:

{
  "error": {
    "message": "Token is for previous version of the universe, please generate a new one : \"eyJhbGciOi...\"",
    "code": "SOME_OUTDATED_TOKEN_ERROR_CODE",
    "data": {
      "token": [
        "Token sent is for version XX, latest is YY, see YY changelog here https://spacetraders.io/changelog/YY"
      ]
    }
  }
}
space-admiral commented 1 year ago

Thanks for filing this issue! We deployed better errors for token mistmatch in the last reset. Let me know what you think and if you find anything else that can be improved.