Is there any way to be able to see the error message for authentication errors?
They are not logged on the server runtime and the client does not receive them.
The only thing the client receives is a 400 BAD REQUEST.
For this example I sent a request with an ID that is too short
In runtime_go_nakama.go I see it returns an error. return "", "", false, errors.New("expects id to be valid, must be 6-128 bytes")
And in api_authenticate.go there it returns a status error as well. return nil, status.Error(codes.InvalidArgument, "Custom ID invalid, must be 6-128 bytes.")
Ideally we want to be able to read this error message on the client because right now there’s no way for us to know why authentication failed.
We also have some pre auth hooks with custom errors but those are not readable on the client either.
It makes it extremely difficult to debug authentication issues because there can be dozens of causes.
Same issue here, we would like to have the errors thrown by Nakama received in the client. Note that if I do the exact same post request via CURL, we do get a response including the error message. But via the JavaScript SDK we get a general error that authentication failed. The HTTP request made by the SDK is also not containing the errors, but the response on a CURL request is.
Errors we’re looking for are for example these authentication errors, but we would also like to get the errors throw by any before and after hooks.
A CURL request to /v2/account/authenticate/email will give the right errors back in the response, but requests made by the JavaScript SDK do not. Let me know in case anything is unclear, happy to provide more details if needed.
When you catch an error from the Javascript client, it’s returning an error object created by the Fetch API. You can get the server response from the fetch api using await error.json() on the error object. The reason we don’t return this directly is some errors may be connection errors in which case there is no server response, so it’s best to just return the fetch api error directly.
We’ll document this better in the future to save some pain.
I’m pretty sure that the response is coming back as “500: Internal Server Error” – probably due to the use of “error” to interrupt the authentication process. Is there a way (using Lua) to use a Before Hook to stop authentication and return information to the client without invoking “error”? Or, if not, is there a way to ensure that the error message actually reaches the client?
@ReducioAbsurdum could you either PR a fix to nakama-godot to forward along any error messages or file an issue against nakama-godot repository to ask for the functionality?