Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api response statuses #19

Closed
lwasak opened this issue Jun 26, 2018 · 5 comments
Closed

Api response statuses #19

lwasak opened this issue Jun 26, 2018 · 5 comments
Labels
bug Something isn't working ticket created Internal developer ticket has been created. Will go through approval and prioritization.

Comments

@lwasak
Copy link

lwasak commented Jun 26, 2018

Hi,

Is there a list of status responses? For the status field below?

{ "status": 1, "time": 1528334546, "response": { "offer": { "some_data": "here" } } }

I'm looking for a more normal way to detect that an item was already used in trade. Currently I receive such response:

{ "status": 400, "time": 1530010378, "message": "There is an offer #XXXXXX with the same parameters." }

Is status of 400 directly related with this case that item is already used? or does it mean something entirely different.

Can you point me in the right direction?

@rannmann
Copy link
Member

If we haven't setup custom error codes for something yet, it uses the HTTP response code as the status.

Unfortunately that means for now you'll have to parse the message anytime the status isn't 1 in order to figure out what went wrong.

@ha1331
Copy link

ha1331 commented Jul 5, 2018

@rannmann by parse you mean.... what? Is there a list of these possible messages ? So that I can parse something to connect it to a specific failure condition? If not, what am I supposed to parse and why? The only way I have been able to track these is, do stuff, do more stuff, something goes wrong and then you look at the message to figure out what's going on, but that is very tedious effort and you only catch the ones you are able to trigger. Now I guess I'm parsing the message, but it's not like parsing is the solution. The solution is to do your best to collect the possible failure condition and then prepare for those accordingly, only now will the parsing be part of a solution. But you are not likely going to be able to parse your way out of failures you have no idea are possible.

edit for further elaboration to not sound like I'm salt mining:
The point I'm trying to make here is, if the issue is, "how do I prepare my implementation to account for the failure modes" the answer can't be "parse the message", when you're required to do some creative message uncasing (pun intended) to even know the failure modes in the first place. Parsing the message is just the 5% of the solution. Not that different to matching the status code to what ever it is you want to connect it to.

The biggest worry I have here is, this whole ExpressTrades thing can easily become another Steam, but instead of Gaben (praise the lord), we're trying to get along with Opskins and figure out what the flavor of the month peculiarity will be. This is not meant to be criticism against ExpressTrades or Opskins for that matter. It's just a difference between do you wan't to create a service that primarily serves opskins interests and the rest of us are free to use it, but it comes with it's opskins maintenance tuesdays and "parse the message mate" types of caveats. I personally don't mind either way but if I had the opportunity to choose, I would prefer you create a thing that is meant to be consumed by 3rd parties instead of a thing that can be consumed by 3rd parties.

@Voyager-Two
Copy link
Contributor

Voyager-Two commented Jul 6, 2018

I think it would be helpful to update the API endpoints with possible status it could output.

Here are the status codes used, almost all should match an OPSkins Error Code, which have descriptions here.

1xx user account errors
2xx internal errors
3xx user error
4xx third party error

I will add this to the documentation as well when I get a chance.

JS Object:

const ErrorCodes = {
  OK: 1,

  GENERIC_USER_ACCOUNT_ERROR: 102,
  ACCESS_DENIED: 106,
  NOT_LOGGED_IN: 108,
  NEEDS_TWOFACTOR: 112,
  TWOFACTOR_INCORRECT: 122,
  USERNAME_TAKEN: 124,
  UNACCEPTABLE_USERNAME: 126,

  GENERIC_INTERNAL_ERROR: 202,
  DATABASE_ERROR: 204,
  NOT_FOUND: 206,
  BAD_STATE: 208,
  NO_MATCHING_ITEMS_FOUND: 210,
  CANNOT_CREATE_DIRECTORY: 216,
  FILE_UPLOAD_ERROR: 218,
  FILE_UPLOAD_ALREADY_EXISTS: 220,
  CANNOT_DELETE_FILE: 222,
  ALREADY_IN_THAT_STATE: 226,
  LOCKED: 228,
  DISABLED: 234,
  MALFORMED_RESPONSE: 236,
  EXPIRED: 238,
  EMPTY_DATA: 240,
  ITEM_NEEDS_REPAIR: 246,
  ITEM_NOT_IN_INVENTORY: 248,

  BAD_INPUT: 302,
  UNACCEPTABLE_ITEM: 304,
  DUPLICATE_ITEM: 306,
  BAD_REQUEST: 312,
  CAPTCHA_INVALID: 316,
  RATE_LIMIT_EXCEEDED: 318,
  MISSING_DEPENDENCY: 326,
  REQUEST_OR_FILE_TOO_LARGE: 330,
  UNACCEPTABLE_FILE_TYPE: 332,

  THIRD_PARTY_UNAVAILABLE: 408
}

PHP Array

$errorCodes = [
    "OK" => 1,
    
    "GENERIC_USER_ACCOUNT_ERROR" => 102,
    "ACCESS_DENIED" => 106,
    "NOT_LOGGED_IN" => 108,
    "NEEDS_TWOFACTOR" => 112,
    "TWOFACTOR_INCORRECT" => 122,
    "USERNAME_TAKEN" => 124,
    "UNACCEPTABLE_USERNAME" => 126,
    
    "GENERIC_INTERNAL_ERROR" => 202,
    "DATABASE_ERROR" => 204,
    "NOT_FOUND" => 206,
    "BAD_STATE" => 208,
    "NO_MATCHING_ITEMS_FOUND" => 210,
    "CANNOT_CREATE_DIRECTORY" => 216,
    "FILE_UPLOAD_ERROR" => 218,
    "FILE_UPLOAD_ALREADY_EXISTS" => 220,
    "CANNOT_DELETE_FILE" => 222,
    "ALREADY_IN_THAT_STATE" => 226,
    "LOCKED" => 228,
    "DISABLED" => 234,
    "MALFORMED_RESPONSE" => 236,
    "EXPIRED" => 238,
    "EMPTY_DATA" => 240,
    "ITEM_NEEDS_REPAIR" => 246,
    "ITEM_NOT_IN_INVENTORY" => 248,
    
    "BAD_INPUT" => 302,
    "UNACCEPTABLE_ITEM" => 304,
    "DUPLICATE_ITEM" => 306,
    "BAD_REQUEST" => 312,
    "CAPTCHA_INVALID" => 316,
    "RATE_LIMIT_EXCEEDED" => 318,
    "MISSING_DEPENDENCY" => 326,
    "REQUEST_OR_FILE_TOO_LARGE" => 330,
    "UNACCEPTABLE_FILE_TYPE" => 332,
    
    "THIRD_PARTY_UNAVAILABLE" => 408
];

PHP consts:

    const OK = 1; // no error

    // 1xx = user account error
    const GENERIC_USER_ACCOUNT_ERROR = 102;
    const ACCESS_DENIED = 106;
    const NOT_LOGGED_IN = 108;
    const NEEDS_TWOFACTOR = 112;
    const TWOFACTOR_INCORRECT = 122;
    const USERNAME_TAKEN = 124;
    const UNACCEPTABLE_USERNAME = 126;

    // 2xx = internal error
    const GENERIC_INTERNAL_ERROR = 202;
    const DATABASE_ERROR = 204;
    const NOT_FOUND = 206;
    const BAD_STATE = 208;
    const NO_MATCHING_ITEMS_FOUND = 210;
    const CANNOT_CREATE_DIRECTORY = 216;
    const FILE_UPLOAD_ERROR = 218;
    const FILE_UPLOAD_ALREADY_EXISTS = 220;
    const CANNOT_DELETE_FILE = 222;
    const ALREADY_IN_THAT_STATE = 226;
    const LOCKED = 228;
    const DISABLED = 234;
    const MALFORMED_RESPONSE = 236;
    const EXPIRED = 238;
    const EMPTY_DATA = 240;
    const ITEM_NEEDS_REPAIR = 246;
    const ITEM_NOT_IN_INVENTORY = 248;

    // 3xx = user error
    const BAD_INPUT = 302;
    const UNACCEPTABLE_ITEM = 304;
    const DUPLICATE_ITEM = 306;
    const BAD_REQUEST = 312;
    const CAPTCHA_INVALID = 316;
    const RATE_LIMIT_EXCEEDED = 318;
    const MISSING_DEPENDENCY = 326;
    const REQUEST_OR_FILE_TOO_LARGE = 330;
    const UNACCEPTABLE_FILE_TYPE = 332;

    // 4xx = Third party error
    const THIRD_PARTY_UNAVAILABLE = 408;

@rannmann rannmann added the ticket created Internal developer ticket has been created. Will go through approval and prioritization. label Jul 13, 2018
@rannmann
Copy link
Member

Added an internal ticket to go back and fix all the instances where HTTP status codes are the error code in the API response.

@rannmann rannmann added the bug Something isn't working label Jul 13, 2018
@rannmann
Copy link
Member

Error codes have been updated for API endpoints so they no longer show the HTTP Status code as the error code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ticket created Internal developer ticket has been created. Will go through approval and prioritization.
Projects
None yet
Development

No branches or pull requests

4 participants