question

jonas.barnaby@gmail.com avatar image
jonas.barnaby@gmail.com asked

Problems with RegisterPlayFabUser API call error messages

Hi all.   I'm currently using the Unreal Engine SDK to make calls and I'm coming up with some doubts about the process, hope you guys can help.   First of all, I've been unable to trigger the 1005, 1007, 1008 and 1009 error codes. I was working under the assumption that these error codes would be obtained by passing their correspondent invalid fields on the API call (Email, username and password), but instead I'm receiving a 1000 error on each of them. For example, the passing of an invalid username is triggering a 1000 error instead of a 1007. How can I test these error codes?   Besides, I'm getting some confusing messages while testing other errors. Here they are:   - On an invalid password (meaning a string with a non alphanumeric character such as an underscore) I'm receiving a 1000 error with a " Password must be between 6 and 30 characters", which is a non descriptive information about the error which triggered the response. Should I be getting a 1008 error message instead? - When trying to register a username that already exists with a new email address I'm getting a 1000 error with the message " Password must be between 6 and 30 characters". - When trying to register an existent username with an existent but not unmatching email address we're receiving a 1006 error and a " Email address already exists" message. Should it return a message for the existent username as well or is this the intended behaviour? - When trying to register a blank username (with the rest of the fields correctly setted) we receive a 1000 error with a " Both username and email are required unless especified with RequireBothUsernameAndEmail" message, which is the same error we get when trying to register a new user with a blank email field and the other fields correct. This prevents us of knowing which field was not setted before the call unless we perform this validation on a code level. - When trying to register a user without a proper email format (i.e., any string without an @) we get a 1000 error message. Should we get a 1005 error instead? - When trying to register an already existent user with a new email address we get a 1006 error with the message " Email address already exists". It's the user who already exists, not the email address.   Thanks in advance, Alberto
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

First, I would agree with Hamza, that all the error codes should be checked. It is the case that you will not get back all the error codes for all the things wrong with a call, if multiple things are wrong with the call in question - it will early-out on the first error encountered and return the specific response info for that problem.

We do have a bug open to review the error codes returned, to ensure that the information returned is accurate. Because this hasn't been called out as an issue by most developers (Hamza was, as he said, the first reporter for this), it has not been prioritized as yet. We're using our Bugs forum as a way for developers to help let us know which items are most impacting (via votes), so I'm moving this post there, so that it can be found more readily.

However, in my own testing, I do see two differences from your tests when calling RegisterPlayFabUser:

  • Called with an already-used Username, but a unique email address, does return a 1009:

{"code":400,"status":"BadRequest","error":"UsernameNotAvailable","errorCode":1009,"errorMessage":"UsernameNotAvailable","errorDetails":{"Username":["User name already exists."]}}

  • Called with an already-used email address, but a unique Username, does return a 1006:

{"code":400,"status":"BadRequest","error":"EmailAddressNotAvailable","errorCode":1006,"errorMessage":"EmailAddressNotAvailable","errorDetails":{"Email":["Email address already exists. "]}}

If you're not seeing this, can you provide the specifics - Title ID, PlayFab ID of the existing user(s), specifics of the call being made?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hamza Lazaar avatar image
Hamza Lazaar answered

Hey Alberto, you definitely should make validation at "code level". That's what I'm doing and it's what the login samples on github exposes also. I know it's a lot of work to check each input field for the different login or register screens. 

And at the same time, PlayFab should seriously consider fixing those error codes. I remember reporting similar issue months ago. 

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jonas.barnaby@gmail.com avatar image
jonas.barnaby@gmail.com answered

Thanks for the responses, Brendan and Hamza.

Brendan, you're right, the error codes for this two cases are indeed 1009 and 1006. When I checked the tests I realized that the password we were using for them was too short, hence the wrong error code. As you said, I was getting the first error encountered. Once I tried a proper password I got the correct error code.

For the field validation we'll implement the necessary measures to check the strings before making the call, avoiding further unnecesary complications.

Thanks again for your help,

Alberto.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

mihneabalta avatar image
mihneabalta answered

This still doesn't work correctly:

  • passing an invalid email or password returns error 1000, instead of 1005 and 1008
  • passing a display name that's already taken returns error 1058, which is not documented

It would also be great if you could add a CloudScript hook for validating display names. For example, we want to allow only alphanumeric characters, plus underscores and dashes.

,

This still doesn't work:

  • using an invalid email or password returns error 1000, instead of 1005 and 1008
  • using a display name that's already taken returns error 1058, which is not documented
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

The return values are correct, but the docs need an update - I'll work with the tools team on that. Errors for your scenarios are:

Bad username or email address (doesn't exist in the title) - 1001 - AccountNotFound

Bad email address (malformed) - 1000 - InvalidParams

Bad username or password (too short/long) - 1000 - InvalidParams

Bad password (incorrect) - 1003 - InvalidUsernameOrPassword

Username already taken - 1009 - UsernameNotAvailable

Title Display Name already taken - 1058 - NameNotAvailable

If you have any scenarios not covered here, can you specify what the API call is that you're making, and what your repro steps are?

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

mihneabalta avatar image mihneabalta commented ·

Hi,

I think there's a small confusion here. RegisterPlayFabUser can't return AccountNotFound or InvalidUsernameOrPassword, right? LoginWithEmailAddress can throw those error codes, but why would register complain about failed logins?

Anyway, I'm fine with getting InvalidParams for malformed email or password, as long as I can tell what happened. I see that errorDetails contains keys such as "Email" which I can use, but those are strings, so I'm a bit uncomfortable with them. Are they part of the API contract, and covered by regression tests? Can you put those keys in the docs as well? It wouldn't be very nice if someone changes "Email" to "email", and my game no longer understands what went wrong, and cannot communicate the error to the user (by highlighting the offending field in the register form).

0 Likes 0 ·
brendan avatar image brendan mihneabalta commented ·

Correct, sorry for the confusion. RegisterPlayFabUser is specifically used to created an account, not to sign into one. So neither of those errors would make sense for it. I simply traced the logic for auth in general, to make sure I could provide the full set of all possible returns, but you are correct that those two are in code paths that RegisterPlayFabUser wouldn't follow.

We do thorough testing on all API calls. I'll add a work item for the tools team to add documentation for the errorDetails in addition.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.