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

Sign Up throws BadRequestException #166

Open
MilesLitteral opened this issue Jul 22, 2024 · 4 comments
Open

Sign Up throws BadRequestException #166

MilesLitteral opened this issue Jul 22, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@MilesLitteral
Copy link

MilesLitteral commented Jul 22, 2024

Bug report

Describe the bug

A clear and concise description of what the bug is.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

Note: Confirm you have new user sign up enabled

  1. Initialize Supabase and Auth client
  2. Call supabase.Auth.SignUp(<email>, <password>);
  3. Run
  4. See error BadRequestException:
{
    "component":"api",
    "error": "400: Could not parse request body as JSON:
        json: cannot unmarshal array into Go value of: 
        type struct {
            Email string \"json:\\\"email\\\"\"; 
            Phone string \"json:\\\"phone\\\"\" 
        }",
    "level":"info","method":"POST","msg":
        "400: Could not parse request body as JSON: 
        json: cannot unmarshal array into Go value of
        type struct { 
            Email string \"json:\\\"email\\\"\"; 
            Phone string \"json:\\\"phone\\\"\"
        }",
    "path":"/signup",
    "referer":"https://nltzzlfvjiejvzpuyigo.supabase.co/auth/v1/callback",
    "remote_addr":"98.116.40.56",
    "request_id":"8a74ad0f3776422f-EWR",
    "time":"2024-07-22T16:06:05Z"
}

Expected behavior

Sign Up user acknowledged in dashboard

System information

  • OS: Windows
  • Browser (if applies): Unity
  • Version of supabase-C#: 3.10?

Additional context

Add any other context about the problem here.

@MilesLitteral MilesLitteral added the bug Something isn't working label Jul 22, 2024
@MilesLitteral
Copy link
Author

MilesLitteral commented Jul 23, 2024

I discovered that SignUp's var body = new Dictionary<string, object> { { "email", email }, { "password", password } }; is actually not writing to JSON correctly and is thus leading to error code 400 (malformed/bad request) responses. I wrote a new SignUp function using the UserAttributes class and will make a pull request as it does work correctly and creates users without error (ie: calling the function creates users on the Supabase dashboard and does serialize to json as the /signup endpoint desires.)

@acupofjose
Copy link
Contributor

A PR is always welcome! Thanks @MilesLitteral

@acupofjose
Copy link
Contributor

@MilesLitteral, I'm looking into your PR - I'm struggling to duplicate the malformed request issue you're seeing.

If it's a general issue, it should be present when testing in our CI against the latest released tag on the supabase/gotrue repo. I did update the repo because it was using an old tag for testing - but I'm not seeing any issue when testing against the SignUp method.

This makes me think it's a Unity issue - potentially a conflict between System.Text.Json and Newtonsoft.Json. Thoughts?

@MilesLitteral
Copy link
Author

@MilesLitteral, I'm looking into your PR - I'm struggling to duplicate the malformed request issue you're seeing.

If it's a general issue, it should be present when testing in our CI against the latest released tag on the supabase/gotrue repo. I did update the repo because it was using an old tag for testing - but I'm not seeing any issue when testing against the SignUp method.

This makes me think it's a Unity issue - potentially a conflict between System.Text.Json and Newtonsoft.Json. Thoughts?

That's possible, I was under the impression it could be a general error because this issue came up when calling sign up regardless on my system though it could be a separate issue, however this function definitely works in Unity out of the box as the request isn't malformed when sending a UserAttributes object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants