Authentication errors not received on client (Only 400 BAD REQUEST)

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.

{
    url: 'http://localhost:7650/v2/account/authenticate/custom?create=true&username=sdk-test&',
    status: 400,
    statusText: 'Bad Request',
    headers: Headers { [Symbol(map)]: [Object: null prototype] },
    counter: 0
}

Here is the full response

# Setup

Javascript frontend

  • nakama-js 2.3.0

Golang backend

  • nakama-common v1.22.0
  • nakama 3.11.0

Bumping this for visibility, would be great to get an answer on this.

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.

Is there a way to get this data in Godot 4? I am attempting to use

error( "Invalid Custom ID" )

to provide information back to the client, but the only information received by the client is

NakamaException(StatusCode={2}, Message='{HTTPRequest failed!}', GrpcStatusCode={-1})

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?

Yes, I’ll do that as soon as I can.

Thank you for the guidance!

Sorry I didn’t add this sooner, but perhaps I should have; the link is available at Pass Error Information to Godot 4 client · Issue #187 · heroiclabs/nakama-godot · GitHub